Hello,
I am a complete newbie to stata but I need help, would greatly appreciate any help.
I have created a variable where a list of variables is categorised into two categories. There are 11 variables i need to categorise into a binary category. In this variable, I want the variable to be counted as 1 in any cases of 1 being selected from variable list ( e.g. var1=1 var2=2, var3= 0, var4=2 still to be counted as 1). And if all variables are scoring as 0 or 3 i wanted it to categorise into 0.
gen newvar= .
recode newvar .= 1 if var 1 ==1 | var 2==1| var3==1| var4==1
recode newvar .= 0 if var 0 ==0| var 2==0| var3==0| var4==0
but this did not account for missing data.
Essentially i want newvar= 1 if any of the list of variables = 1, = 0 if the list of variables are equal to 0 or 2. BUT, if there are more than 30% of missing data for for the variables, for this to be categorised as missing (unless there is any instantce of 1 selected)
so that e.g.
var1=1 || var2=2 || var3= 0 || var4=2 || var5=0 || var6= 2 || var7= . || var8=2 || var9=2 || var10=2 || var11= 0 **this would lead to category 1 in newvar (as var1 has a value of 1)
var1= 0|| var2=2 || var3= 0 || var4=2 || var5=0 || var6= 2 || var7= . || var8=2 || var9=2 || var10=2 || var11= 0 **this would lead to category to category 0 in newvar ( as there are no variables with 1, and only 1 variable is missing data**
var1= . || var2=2 || var3= . || var4=. || var5=0 || var6= . || var7= 0 || var8=2 || var9=2 || var10=2 || var11= 0 **i want this to be categorised as missing, as >4 variables are missing & no variable is equal to 1).
i created a variable of missing data using
egen= miss= rowmiss (list of 11 variables)
I tried adding to the recode new command if miss=3 i.e. recode newvar .= 0 if var 0 ==0| var 2==0| var3==0| var4==0 etc miss==3
but it didn't do anything...
Any help would be much appreciated
I am a complete newbie to stata but I need help, would greatly appreciate any help.
I have created a variable where a list of variables is categorised into two categories. There are 11 variables i need to categorise into a binary category. In this variable, I want the variable to be counted as 1 in any cases of 1 being selected from variable list ( e.g. var1=1 var2=2, var3= 0, var4=2 still to be counted as 1). And if all variables are scoring as 0 or 3 i wanted it to categorise into 0.
gen newvar= .
recode newvar .= 1 if var 1 ==1 | var 2==1| var3==1| var4==1
recode newvar .= 0 if var 0 ==0| var 2==0| var3==0| var4==0
but this did not account for missing data.
Essentially i want newvar= 1 if any of the list of variables = 1, = 0 if the list of variables are equal to 0 or 2. BUT, if there are more than 30% of missing data for for the variables, for this to be categorised as missing (unless there is any instantce of 1 selected)
so that e.g.
var1=1 || var2=2 || var3= 0 || var4=2 || var5=0 || var6= 2 || var7= . || var8=2 || var9=2 || var10=2 || var11= 0 **this would lead to category 1 in newvar (as var1 has a value of 1)
var1= 0|| var2=2 || var3= 0 || var4=2 || var5=0 || var6= 2 || var7= . || var8=2 || var9=2 || var10=2 || var11= 0 **this would lead to category to category 0 in newvar ( as there are no variables with 1, and only 1 variable is missing data**
var1= . || var2=2 || var3= . || var4=. || var5=0 || var6= . || var7= 0 || var8=2 || var9=2 || var10=2 || var11= 0 **i want this to be categorised as missing, as >4 variables are missing & no variable is equal to 1).
i created a variable of missing data using
egen= miss= rowmiss (list of 11 variables)
I tried adding to the recode new command if miss=3 i.e. recode newvar .= 0 if var 0 ==0| var 2==0| var3==0| var4==0 etc miss==3
but it didn't do anything...
Any help would be much appreciated
Comment