Hi!
I am currently working on a fairly large dataset (with 700 + observations). I want to give different values for some of the variables in the data set. The data is based on a questionnaire, and is currently coded as for example:
x1=-2 for "refused"
x1=-1 for "don't know"
x1=1 for "yes"
x1=5 for "no"
I want to replace the variables' values, without generating new variables, and have tried the following command:
This seems to work, however, I get the labels "0" and "yes" instead of 0 and "no" and "yes" - as seen below
I've tried adding the following:
but then i get "Syntax error".
I hoped I expressed myself in an understandable way.
Thank you
I am currently working on a fairly large dataset (with 700 + observations). I want to give different values for some of the variables in the data set. The data is based on a questionnaire, and is currently coded as for example:
x1=-2 for "refused"
x1=-1 for "don't know"
x1=1 for "yes"
x1=5 for "no"
I want to replace the variables' values, without generating new variables, and have tried the following command:
Code:
foreach v of varlist rh040_ rh042_ rh780_ rh792_ br002_ { replace `v'=1 if `v'==1 replace `v'=0 if `v'==5 | `v'==-2 | `v'==-1 }
Code:
tab rh040_ x1 | Freq. Percent Cum. ------------+----------------------------------- 0 | 1,185 60.58 60.58 Yes | 771 39.42 100.00 ------------+----------------------------------- Total | 1,956 100.00
I've tried adding the following:
Code:
foreach v of varlist rh040_ rh042_ rh780_ rh792_ br002_ { replace `v'=1 if `v'==1 replace `v'=0 if `v'==5 | `v'==-2 | `v'==-1 rename `v'="No" if `v'=0 }
I hoped I expressed myself in an understandable way.
Thank you
Comment