Thursday, October 8, 2020

Stata Tip: Best Advice on Writing Dofiles

Yes, I know you're excited to see the results of your regression. Go ahead and be sloppy with your coding. You probably will make mistakes. You'll go back to fix them. Maybe that's fine. But at some point, go through these J-Pal instructions and guidelines on how to clean your data. The big rules: 

  1. Document decisions
  2. Never overwrite the original/raw data file
Other gems include: Look at the distribution of every variable you use in your analysis (do you have 500 year olds? Are the missing values set to 99?) Do you see anything suspicious? The more you know about the data, the better. 

Also, use Stata's help command to learn more about "mvdecode" and "subinstr."  And remember to rename variables so that you can tell what they are by looking at the variable (hint: a dummy variable called "male" is more helpful than one called "sex"). Label the values so that you don't have to keep going back to the codebook. 

No comments:

Post a Comment