Stata 15, Windows 10
I'm iterating over a set of datasets looking for particular variables, some are not in all datasets.
I can't figure out how to have stata drop variables that aren't in the list or keep only the variables that appear in the list.
If I type keep var1, var2, var3, and that particular dataset doesn't have var2, I get an error and nothing happens. So as the do file iterates over the datasets, it stops when it encounters this and doesn't drop the variables I'm not interested in.
Any suggestions?
I'm iterating over a set of datasets looking for particular variables, some are not in all datasets.
I can't figure out how to have stata drop variables that aren't in the list or keep only the variables that appear in the list.
If I type keep var1, var2, var3, and that particular dataset doesn't have var2, I get an error and nothing happens. So as the do file iterates over the datasets, it stops when it encounters this and doesn't drop the variables I'm not interested in.
Any suggestions?
Comment