1 / 6

Problem Set 1

Problem Set 1. Troubleshooting. Log Files. Save in text format for readability: l og using ps1 .log , replace o r: log using ps1, text. Handling Missing Values. By default, Stata excludes all observations marked with a period (.) from subsequent statistical analysis. Best practices:

moral
Download Presentation

Problem Set 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Problem Set 1 Troubleshooting

  2. Log Files Save in text format for readability: log using ps1.log, replace or: log using ps1, text

  3. Handling Missing Values • By default, Stata excludes all observations marked with a period (.) from subsequent statistical analysis. • Best practices: • Recode appropriate survey responses to missing. Safest: replace v1 = . if v1 == 6 • Do not drop observations with missing values. • Be careful not to recode missing values by accident.

  4. Handling Missing Values Problematic: gen dummy1 = 0 replace dummy1 = 1 if v1 == 4 | v1==5 Safe: gen dummy1 = . replace dummy1 = 1 if v1 == 4 | v1==5 replace dummy1 = 0 if v1 <= 3 gen dummy1 = 1 if v1 == 4 | v1==5 replace dummy1 = 0 if v1 <= 3

  5. Handling Missing Values Stata handles ‘.’ as higher than any integer value. Will recode missing observations: replace dummy1 = 1 if v1 > 6 Safe: replace dummy1 = 1 if v1 > 6 & v1 != .

  6. Optional: PS2 Time Saver Stata supports loops: foreach x of numlist1800 1850 1870 1900 1920 1950 1970 1975 { sum spending if year==`x', detail } foreach x of varlistgdpcap pop taxhead race* { gen log_`x’ = log(`x’) sum `x’, detail hist `x’, name(`x’) }

More Related