In the following data, I want to replace variables d2a1 d2a2 d2a3 to missing 'cause variable d2a <100. Now I must type as many command lines as certain conditions.
Code:
replace d2a1=. if d2a==29 replace d2a1=. if d2a==8 replace d2a2=. if d2a==50 replace d2a3=. if d3a==50 ......
Code:
replace d2a1=. if d2a<100 replace d2a2=. if d2a<100 replace d2a3=. if d3a<100
Code:
d2a1 d2a2 d2a3 d2a4 d2a 29 0 0 2500 29 8 0 0 0 8 0 50 0 20000 50 50 0 1 5000 50 0 1 0 30000 1 0 21 0 30000 21 50 0 7 5000 57 10 50 0 20000 60 29 0 1 2500 30
0 Response to How to replace any variable's value if meeting certain condition
Post a Comment