I would like to ask you a very simple question regarding loop.
I want to make a variable for each of countries listed in my data. As there are many items, I would like to automate this process by using loop function.
Code:
global X 1 2 3 4 5 6 7 8 9 10 11 foreach x of global X { foreach y in 22.26 33.98 16.6 30.16 21.06 11.36 36.29 46.28 64.31 110.56 36.83 { gen unit_physio_`x'= `y' } }
This is my code. In fact what I want is unit_physio_1 = 22.36, unit_physio_2=33.98, unit_physio_3=16.6
However, all of them are 22.26 after I run this code.
I would be happy if someone helps me with this problem.
Many thanks in advance.
Kind regards,
kim
0 Response to Simple loop question
Post a Comment