Dear statalist,
I'm trying to program the following commands more mechanically:
One problem is that the code is supposed to run through various datasets and the number of variables may vary each time (e.g. in this particular data there are the variables intentionof14-intentionof112 but for another data download there may be more variables, say intentionof14-intentionof118). Therefore I cannot use the actual numbers in the commands. I let stata read out the number of variables first and then use two foreach loops:
Obviously, this does not work because stata runs one loop after the other while I would need some command to run through both loops simultaneously. Maybe forvalues is not the right approach. Can anyone help?
Thank you,
Sarah Linde
I'm trying to program the following commands more mechanically:
Code:
rename intentionof14 intentionof6 rename intentionof18 intentionof7 rename intentionof112 intentionof8
Code:
split intentionof, p(",") drop intentionof ds intentionof* local number13: word count `r(varlist)' display `number13' 5 split intentionof1, p("#", "|") drop intentionof1 ds intentionof1* local number14: word count `r(varlist)' display `number14' 12 local number15 = `number13'+1 local `number16' = `number14'-4 forvalues i=4(4)`number14' { forvalues j=`number15'/`number16' { rename intentionof1`i' intentionof`j' } }
Thank you,
Sarah Linde
Comment