Hey,
I am currently in the middle of a project that involves analysing a time diary, and I wish to create a variable measuring how many times certain activities were performed by all participants.
I currently have these commands:
gen no_act = 0
replace no_act = no_act + 1 if pri1 == 127 | pri1 == 133 | pri1 == 128 | pri1 == 108 | pri1 == 135 | pri1 == 132 | pri1 == 131 | pri1 == 129 | pri1 == 136
The issue is that each diary interval is contained in a separate variable (from pri1 to pri144). I want to run this command for all 144 variables, but feel as if it it is inefficient to re-write the command 144 times.
Is there any way I can automate this task, perhaps with python?
Sorry, am very new to this
Thanks
I am currently in the middle of a project that involves analysing a time diary, and I wish to create a variable measuring how many times certain activities were performed by all participants.
I currently have these commands:
gen no_act = 0
replace no_act = no_act + 1 if pri1 == 127 | pri1 == 133 | pri1 == 128 | pri1 == 108 | pri1 == 135 | pri1 == 132 | pri1 == 131 | pri1 == 129 | pri1 == 136
The issue is that each diary interval is contained in a separate variable (from pri1 to pri144). I want to run this command for all 144 variables, but feel as if it it is inefficient to re-write the command 144 times.
Is there any way I can automate this task, perhaps with python?
Sorry, am very new to this
Thanks

Comment