//homepage‎ > ‎/courses‎ > ‎

Health Services Research Methods (PHPM 672)

> Introduction Materials

.  syllabus

Here is a copy of the syllabus . 

.  file access

To access PDF files, get a free copy of Adobe Reader.
To open ZIP files, get a free copy of ZIP Readers for Windows or OSX

.  class materials

You can download the class materials for each week in a .ZIP file. 

Each ZIP file contains the following types of files:

1. Lecture Slides**

  a. LECTURE.smcl - which contains the class lecture slides.   .smcl files are slides that run interactively in Stata; that is, you can click the blue text in these slides, and it will run the commands in the "Results" window in Stata.  

To view & use these slides, extract the files from the zip file and double click the "LECTURE.smcl" slide--it will open in Stata automatically (this must be done on a computer with Stata installed...if you do not have Stata, you can use the PDF version of the slides). 
  b.  Please ignore the "ignore" folder as it contains behind-the-scenes files to make some of the slides and  class examples work.  Also ignore the "_MACOSX" folder as it is just a system folder created by macs when zipping folders.

Here's what the Stata .smcl slide looks like:

Use the arrows "<<<" and ">>>" to navigate from one slide to the next.  Click "TOC" at the top of the slide to return to the Table of Contents slide.

2. Homework Materials

3. Example Datasets & Do-files for the lecture or homework


. Viewing Slides

**You need to download the file "slideviewer.ado" which is a Stata program that allows you to view and advance through the LECTURE.smcl slides.  

Get -slideviewer- from SSC by typing into your Command window:

ssc install slideviewer, replace

Alternatively, copy this code into your Stata command window and press return:
cap mkdir `"`c(sysdir_personal)'"'
copy "http://eab-adofiles.googlecode.com/files/slideviewer.ado" `"`c(sysdir_personal)'/slideviewer.ado"', replace public 
Download it from the link below and then copy it to your ado path (probably C:\ado\personal\ (Windows)  or  \Users\username\Library\Application Support\Stata\ado\personal (Mac OSX)).
Download slideviewer.ado

>Session 1


Session 1 – Introduction to Stata  [Jan 18]     Learning Objectives: Stata setup, interface, windows; Resources and help files; Do Files and Editors; Loading, importing, converting, and inputing data; Listing and browsing data; Variable and data storage types/formats; syntax rules introduction.
 Reading:  Juul Sections 1 and 2 and Appendix A & C; 
Review “A Sample Stata Session” from the Stata website:  http://www.stata.com/capabilities/session.html ;  
 (Acock Sections 1 and 2)

Class Materials

Download Class Lecture and Homework (BE SURE TO UNZIP AND EXTRACT THIS FOLDER!!):

Other Information
 a) Read through the [GS] (getting started with stata) manual entry here:      
  or by typing -help gs- in the Stata command window and opening the "Starting stata - sample session" module.

b)  Tips on importing data into Stata.    
First off, a good general rule to remember is to use -insheet- with raw, ASCII formatted text files like .csv or .txt.  These are files that you can open directly in notepad (or textedit for Mac OSX) and all you see is the data and the delimiter (like a comma or tab).   You should use -import excel- (a compound command) to import MS Excel files (.xls(x)) files.  For any other file type (which are less prevalent), consult the -help import- documentation.  Excel files cannot be read into -insheet- because -insheet- is programmed to parse raw text/ascii data -- that is, it cannot handle the structure/macro/formatting instructions that are in the preamble of proprietary formatted data like .xls(x) or SAS data.

To help clarify this issue, and cover a few other Stata basics, I've created a 4-slide tutorial that is below (be sure to extract these files from the .zip file in order to run it).  
This tutorial is OPTIONAL, but I think it is useful for understanding how to (1) manage Stata preferences (2) understand importing data into Stata and (3) to practice listing and browsing data in Stata. *In particular, Slide 3 Part 2 has some more detail on how to import many different types of data formats and some tips on how to deal with difficult or oddly-formatted (or corrupt) datasets you might encounter (though rare).   We'll discuss data importing a bit more in class next week, but let me know of any questions/issues you have about this. 

    - Do-file to create HW1 Answer key  (warning, do-file uses TeX to generate file)

>Session 2

Syntax rules; logic and condition qualifiers; more on data import & saving; variable manipulation (conversions and cleaning variables); sort and order variables; weighting; do files and log files to manage and track workflow.
Reading:  Re-read material from Session 1;  Juul Sections 3, 4, 5, and 6;    (Acock Section 4).

Class Materials

Other Information

1) If you haven't already, I suggest you spend some time going through the 'tutorial' described in Session 1 (above)

Homework Assignment 2 Answer Key Do-file (rough version, not cleaned up)

>Session 3

recoding and rescaling data; labeling variables and values; exporting data to other programs; generating variables using formulas and functions; recoding, replacing, and dropping data; explicit subscripting, the “by” construct/prefix.
Juul 7, 8; (Acock Section 3)

Cox, NJ 2007. Speaking Stata: Making it count.  Stata Journal 7(1).  

Cox, NJ 2002.  Speaking Stata: How to move step by: step.  2(1).  

Class Materials

Download Class Slides here  

Other Information
Download the logging program here and paste it in your '/ado/personal/' folder:

>Session 4

Comparing datasets, append/merge/combine data; transpose/reshape data; collapse and aggregate data                    
Readings:  Juul 9, 10

Class Materials

Other Information

1. slideviewer update
-slideviewer.ado-  is now available from SSC.  To install from SSC, type into the Command Window:

    ssc install slideviewer, replace

2.  Homework 3 Supplemental/Practice Exercise:
    Some students have requested more practice data/exercises for combining data.  Here is an exercise to clean and combine hospital, patient, and physician records.  The instructions are included in the .txt file in this zip file (be sure to extract all these files).

    Click to Download HW3 Supplement Exercises here.
    Update:  Here is another HW3 Supplemental Exercise (Supplemental Exercise #2) for practicing data combinations.


3.  Homework 3 Answer Key Do-file (click to download)

>Session 5

Programming:  Macros (global/local); data management programming; looping; tokenizing lists; ado-files; automating tasks with scripting/programs
Reading: Juul Section 18; 
     Cox, NJ. 2001.  How to repeat yourself without going mad.  Stata Journal 1(1).  http://www.stata-journal.com/sjpdf.html?articlenum=pr0003
     Cox, NJ  2003.  Speaking Stata:  Problems with lists.  Stata Journal 3(2).  

Class Materials


Other Information

-slideviewer.ado-  is now available from SSC.  To install from SSC, type into the Command Window:
    ssc install slideviewer, replace

>Session 6

Summary and Descriptive tables

Class Materials
Download Session 6 Lecture Materials here

Download  Homework Assignment #4

Other Information

>Session 7

Stata Graphs and Plots

Class Materials
Download Session 6 Lecture Materials here

Other Information
Next class is the in-class Mid-term exam.

>Session 8: MIDTERM EXAM

>Session 8a: Mid-Semester Recap

>Session 9

Topics:  Variable Comparisons, Distributions, and Hypothesis Testing

Note: You should double click to open the LECTURE.smcl file to view this lecture.  There are other supplementary datasets and do-files in this main folder, but you will be prompted to use those files at different points during the lecture/tutorial. 
Keep notes on the parts of this tutorial/lecture that are troublesome, and we'll discuss them during class next week.

>Session 10

Topics:  Random Data, Stratified & Case-control Analysis, Working with Groups/Panels

Click to download the Log file from Class

>Session 11

Topic: Inference (Anova, Regression, Exporting Estimates Tables)

Class Materials and HW 6:  Click Here

>Session 12

Topic: NHIS data exploration

Class Materials:  Click Here

>Session 13

Topic: NHIS data exploration, Part 2

Class Materials:

>Final Exam