Hello everyone, I am starting to make my first steps on stata. I do several different tests but I encountered a difficulty. Since I have little knowledge of the subject, I would like to ask you the question.
I will save myself in advance if this post has already been posted to and thank you for sending it to me to redirect me.
I have more than 20 str2 variables (car, pets, g_married,
phy_act, ...) . Each variable reviews the answer: Yes, No, Na.
So I used the "replace" command but the problem is that I have to type 3 lines of code to change the set of values by 0 , 1 or . My question is whether there is a way of being able to ask stata to modify directly all the 20 variables at once or without writing each time:
replace car="0" if car =="No"
replace car ="1" if car =="Yes"
replace car ="." if car =="NA"
Thank you in advance to those who will give me an answer.
I will save myself in advance if this post has already been posted to and thank you for sending it to me to redirect me.
I have more than 20 str2 variables (car, pets, g_married,
phy_act, ...) . Each variable reviews the answer: Yes, No, Na.
So I used the "replace" command but the problem is that I have to type 3 lines of code to change the set of values by 0 , 1 or . My question is whether there is a way of being able to ask stata to modify directly all the 20 variables at once or without writing each time:
replace car="0" if car =="No"
replace car ="1" if car =="Yes"
replace car ="." if car =="NA"
Thank you in advance to those who will give me an answer.

Comment