Step 1: Make sure you have Stata on your system.
Next click on the link : ex2.dta to open the data file
Step 2: You have now opened the data file in Stata. Go to the > windows menu and data editor to look at the contents of the data file. You will need to close this before running analyses.
Step 3: Now click on this code file ex2.do and SAVE it
to your computer. DO NOT TRY TO RUN IT YET.
Step 4: Next go back to the Stata package, go to the
menus and click on: Window > Do-File Editor. Now
open the 'do' file you have saved from the do-editor window. Arrange your windows so you can see both the Stata results window and the do file window.
Step 5: Follow the instructions in the 'do' file to run the code.
The instructions are written as comments in the code.