Dear Stata users,
I would like to execute the following command through a loop:
replace q33_1=.a if q29_1 ==.a
replace q33_2=.a if q29_2 ==.a
replace q33_3=.a if q29_3 ==.a
replace q33_4=.a if q29_4 ==.a
replace q33_5=.a if q29_5 ==.a
I already tried with :
forvalues v =1(1)5{
replace q33_`v'=.a if q29_`v'==.a
}
But it's not working. Thank you for your help.
Best,
Jules
Related Posts with Replacing values using a loop
Also testing equations written without a wrapper: \[ \frac{2}{3}+ \mathbf{\pi} \] Using code wrapper: Code: \[ \fra…
Levelsof, local and loops across datasetsHi. I have two datasets both with string variables. The first one has a variable CountryName with na…
Construct pairs of firms across different industriesDear All, I have this dataset Code: * Example generated by -dataex-. To install: ssc install dataex…
reshape data issueHI I am using stata to do relatives in families and use data below. you can see this example below. …
Trouble with Creating Group-Level variableHello, I have a variable that has repeated observations over the life course. Research shows that th…
Subscribe to:
Post Comments (Atom)
0 Response to Replacing values using a loop
Post a Comment