Grad Fellow Notes: Loops in STATA
This week’s blog will feature a set of Stata tricks we used to addresses a particular issue that we encountered in our dataset. Many of the variables were in string form and were not useable for Stata analysis. Furthermore, the values of the variables were not in the correct order for our purposes. A couple of commands came in handy here. Loops are useful for many different repetitive commands. They allowed us to quickly recode the values of a set of variables that have similar categorical values and also enabled us to destring sets of variables, setting them to numeric values. These numeric values were in turn reordered to fit a desired pattern. Finally, the labels for the numeric values were recoded to appear as the original text instead of just “1, 2, 3, etc”.