Hello everyone.
I have a problem with creating my Stata commands. I want to create commands to execute this:
if a9x2round_1 == 1 then
p2_2 = 1 if index_2 == 9
p2_3 = 1 if index_3 == 9
...
p2_60 = 1 if index_60 == 9
if a9x2round_2 == 1 then
p2_3 = 1 if index_3 == 9
p2_4 = 1 if index_4 == 9
...
p2_60 = 1 if index_60 == 9
if a9x2round_5 == 1 then
p2_6 = 1 if index_6 == 9
p2_7 = 1 if index_7 == 9
...
p2_60 = 1 if index_60 == 9
Notice that when the a9x2round_n is 1, then the values of the p2_(n+k)'s must be 1 ---> when a9x2round1 is 1, the value of p2_2, p2_3, and so forth must be 1
How do I create the commands using just one loop, if possible? Because there are numerous variables in my data, I want the codes to be short.
Thank you very much in advance.
I have a problem with creating my Stata commands. I want to create commands to execute this:
if a9x2round_1 == 1 then
p2_2 = 1 if index_2 == 9
p2_3 = 1 if index_3 == 9
...
p2_60 = 1 if index_60 == 9
if a9x2round_2 == 1 then
p2_3 = 1 if index_3 == 9
p2_4 = 1 if index_4 == 9
...
p2_60 = 1 if index_60 == 9
if a9x2round_5 == 1 then
p2_6 = 1 if index_6 == 9
p2_7 = 1 if index_7 == 9
...
p2_60 = 1 if index_60 == 9
Notice that when the a9x2round_n is 1, then the values of the p2_(n+k)'s must be 1 ---> when a9x2round1 is 1, the value of p2_2, p2_3, and so forth must be 1
How do I create the commands using just one loop, if possible? Because there are numerous variables in my data, I want the codes to be short.
Thank you very much in advance.

Comment