Hello!
I am a beginner to STATA and am having issues trying to use loops. I am trying to generate 100 new variables (assigning them an arbitrary value), and label them all using a loop. However, using the code below, only one variable ends up being generated and labeled.
Am I missing a particular command or have I made an error in the code above? Any help would be greatly appreciated.
Thanks!
-Mika
I am a beginner to STATA and am having issues trying to use loops. I am trying to generate 100 new variables (assigning them an arbitrary value), and label them all using a loop. However, using the code below, only one variable ends up being generated and labeled.
Code:
local i destring i, replace local x= 'i'+1 foreach x of numlist 1/100{ generate electricity_x= . label variable electricity_x "electricity x" }
Thanks!
-Mika
Comment