I often need to export extracts of the dataset in memory at the different stages of my workflow, e.g. first without regression results, then with regression results, before a transformation, after a transformation, etc.
To this aim, I end up including code such as the following, where I rely on the same syntax using preserve -> keep -> order -> export -> restore
Is there a better, more efficient and/or more elegant way to go about this?
To this aim, I end up including code such as the following, where I rely on the same syntax using preserve -> keep -> order -> export -> restore
Code:
preserve keep year state iso /// var1 var1a var2a var3a /// x_a1 x_a2 x_a3 b_a1 b_a4 keep if state =="NE" & var1!=. order year state iso /// var1 var1a var2a var3a /// x_a1 x_a2 x_a3 b_a1 b_a4 export excel using "extract1.xlsx", firstrow(variables) replace restore
Comment