Statistics for the

Social Sciences Handout

 

Richard Barton  (rick)                                                                                                 richard.barton@dartmouth.edu

Statistical Consultant                                                                                                  179C Berry Library

Academic Computing


Help

 

http://www.dartmouth.edu/comp/soft-comp/software/statistics/stataintro.html

http://www.dartmouth.edu/comp/soft-comp/software/statistics/statafaq.html

 


Installing Stata and supporting software

 

Stata is free software for Dartmouth students; the current version is 11.

 

Software that you need can be downloaded from     http://www.dartmouth.edu/software   Click on the link for Macintosh Software or Windows Software.  Academic Applications include Stata and KeyAccess.  General Productivity Applications include Stuffit Expander.

 

Students who bought their computers through Dartmouth should already have KeyAccess and Stuffit installed.

 

     1)  Authenticate to the download site using your blitzmail name and password.

     2)  KeyAccess (KSClient) allows you to run keyserved software.  You must be logged on to keyserver.dartmouth.edu to install and run Stata.

     3)  Stuffit (Aladdin) Expander can be used to decompress (unzip) files.

     4)  Stata (Intercooled). 

 

When you download Stata, you may also receive a file called README or license.txt that contains information you may need the first time you run Stata.

 

You should not register your copy of Stata or allow automatic updates.

 


 

Some Stata windows

 

Command  Where you issue Stata command statements.

Results  Shows the commands you've entered and the output of those commands. Upon seeing –more- at the bottom of the window, enter continues and q quits.

Review  Shows the most recent commands entered. Highlighting a command here enters it in the command window.

Variables  Lists the variables in the current data set. Highlighting a variable here enters it in the command window.

Data editor  Opens the current data set in spreadsheet editor. This window must be closed out to return you to the command window.

Graph  Where graphs are displayed.

 


 

Log files

 

A log file can be opened from the File\Log menu.   Open a log file (with a .log extension) when you start a Stata session to keep a record of what you type and Stata's output.

 



Data files

 

Rows are cases, columns are variables.

 

.dta indicates a data file already in Stata format

.txt or .raw indicates data in ASCII (text) formats

.xls indicates data in an Excel file


 

General commands

 

Clear  Clears data out of memory.

Search   If you make a mistake with a Stata command, it may return an error message along with a return code   {for example, r(199)}.  The search command can be used to get a more detailed description of the return code.

Generate   Computes a new variable from an expression.


 

Basic analysis commands

 

Most analysis commands can be followed by a comma and a list of options.

Stata 11 also allows you to do many analyses from the Statistics menu.

 

Tabulate   Gets counts and percents of subgroups for 1 or 2 variables.  

Summarize  Calculates summary statistics such as means and sd’s. 

Correlate   Displays the correlation matrix for a list of variables.  

Regress  Fits a linear regression model of a dependent variable on a single predictor or set of predictors

 


Graphs

Stata 11 allows you to build graphs from the Graphics menu, but it is simpler to build them from the command window.

 

Bar chart

graph bar x y z, options

Histogram

histogram x, options

Scatterplot

scatter y x, options

 


More on data files

 

You may already have a data set that you wish to bring into Stata.  The file can be either:

a)    Spreadsheet format (such as Excel);

b)     Tab (or comma) delimited text format, where variable values always come in the same order in a line

       and separated by the delimiter; or

c)      Fixed column format, where values for the same variable are always in the same set of columns for each

       case  (row).

 

You may need a codebook that indicates the format of the file, what columns hold what variables, how missing values are defined, what value labels should be applied, etc.

 

Use   Opens a data file that is already in Stata format.   The directory path must be specified and can be obtained

         from the File/Filename menu

Insheet  Will read data from a file that is already in a spreadsheet format

Infile  Will read freefield data and tab- or comma-delimited data from a text file

Infix  Will read fixed field data from a text (ASCII) file.

 

insheet id sex using  ':Macintosh HD:Desktop Folder:hsb.raw'   (Mac file path)

insheet id sex using  'c:\my documents\clients\hsb.raw'   (PC file path)