This seminar will introduce the basics of using Stata, SPSS and SAS. It is geared to be a one hour introduction covering just the very basics of these packages for those who need to know just a little about each of these packages (e.g., lab support folks).
Overview
- Data Files
- Like an Excel spreadsheet with rows and columns.
- Each row is an observation, each column is a variable and has a variable name.
- Stata data files
- Version 8 and 7 both end in .dta
- Version 8 can read version 7 files, but version 7 cannot read version 8 files
- SPSS data files
- Version 12.x, 11.x, 10.x all end in .sav
- Version 12.x can read older files, but version 11.x probably will have trouble reading version 12.x files.
- SAS data files
- Version 8.x files end in .sas7bdat
- Version 6.x files end in .sd2
- Version 8.x can read version 6.x files, but version 6.x cannot read version 8.x files.
Homework Problem
- Download the High School and Beyond file.
- Save it on your computer.
- Read the High School and Beyond file into Stata/SPSS/SAS.
- Show descriptive statistics for all of the variables.
- Make a histogram of the writing scores.
- Put into a Word document and print it.
Stata
- Download the High School and Beyond File (method 1: click on https://stats.idre.ucla.edu/stat/stata/notes/hs1.dta and save it to your computer)
- Start Stata
- Read the file into Stata
- cd d:temp (or wherever the file is stored)
- use hs1
- Show descriptive statistics for the variables
- summarize
- Copy and paste results into Word
- Choose Courier font to look better
-
Show histogram for writing score
- histogram write
- Edit – Copy Graph
- Paste into Word. But it pastes in color.
- Prefs – Graph Preferences – Clipboard tab, Color Mapping, grayscale 1
- Method 2 for reading the High School and Beyond file
- use https://stats.idre.ucla.edu/stat/stata/notes/hs1
- save hs1
- How to open a .do file (a file containing a series of Stata commands)
- What help is there?
- Within Stata
- help
- help summarize
- Help pulldown menu
- ATS Web pages
- Stata Web Pages: https://stats.idre.ucla.edu/stat/stata/
- Stata Class Notes (with movies)
- Stata Learning Modules
- Stata FAQs (e.g., How do I copy Stata output and Stata graphs into Word?)
- What statistical analysis should I use?
- Within Stata
SPSS
- Download the High School and Beyond File, click on https://stats.idre.ucla.edu/stat/spss/notes/data/hs1.sav and save it to your computer
- Starting SPSS
- Reading the File
- File –>Open (point to location where we stored hs1.sav)
- Show descriptive statistics for the variables
- Analyze -> Descriptive Statistics -> Descriptives
-
Copy and paste results into Word
- Edit -> Copy, then paste into Word
- Edit -> Copy Objects, then paste into Word
- Compare the two results: the first is a table, the second is a picture
-
Show histogram for writing score
- Graph -> Histogram, pick write
- Edit -> Copy, then paste into Word
- How to open a syntax file (a file containing a series of SPSS commands)
- What help is there?
- Within SPSS
- Help-Topics
- Help Tutorial
- ATS Web pages
- SPSS Web Pages: https://stats.idre.ucla.edu/stat/spss/
- SPSS Class Notes (with movies)
- SPSS Learning Modules
- SPSS FAQs
- What statistical analysis should I use?
- Within SPSS
SAS
- Download the High School and Beyond File, click on https://stats.idre.ucla.edu/wp-content/uploads/2016/02/hs1.sas7bdat and save it to your computer
- Starting SAS
- Show descriptive statistics for the variables
- Attempt #1
proc means data="d:temphs1";
run;
Copy and paste results into Word (be careful not to mark below the end of the output)
Need to switch font to use Courier
May need to make page wider
Lines look lousy - Attempt #2 (sometimes necessary depending on versions of software)
OPTIONS FORMCHAR=’|—-|+|—+=|-/<>*’;
proc means data="d:temphs1";
run;
Copy and past results into Word
Use Courier font, page wide enough. Lines look better.
- Attempt #1
-
Show histogram for writing score
-
proc univariate data="d:temphs1";
var write;
histogram;
run; - Edit -> Copy, then paste into Word (might have to use Paste Special if the graph is in its own window)
-
proc univariate data="d:temphs1";
- You open a SAS program (*.sas), not a SAS data file
- What help is there?
- Within SAS, help probably does not work
- ATS Web pages
- SAS Web Pages: https://stats.idre.ucla.edu/stat/sas/
- SAS Class Notes (with movies)
- SAS Learning Modules
- SAS FAQs
- What statistical analysis should I use?
What other help is available?
- For everyone
- Web pages at https://stats.idre.ucla.edu/stat/
- For Professors, Staff, TAs, Graduate Students (working on research)
- Statistical consulting, see https://stats.idre.ucla.edu/stat/Schedule/
- Consulting is not available to undergrads or for class related work.