Hello,
I am trying to create a dummy variable based on the data available from two other variables. the dummy variable should be 1 if:
gen dummyvar = 0
replace dummyvar = 1 if var1< -1.875 | var1 > 8.325 & var2 < -2.65 | var2 > 10.55
otherwise it should be 0. This works so far, but stata also generates 1 if there are no observations in both var1 and var2. Is there a way to tell stata to keep the dummy variable at 0 if there are no observations in var1 and var2.
Thank you for your help!
I am trying to create a dummy variable based on the data available from two other variables. the dummy variable should be 1 if:
gen dummyvar = 0
replace dummyvar = 1 if var1< -1.875 | var1 > 8.325 & var2 < -2.65 | var2 > 10.55
otherwise it should be 0. This works so far, but stata also generates 1 if there are no observations in both var1 and var2. Is there a way to tell stata to keep the dummy variable at 0 if there are no observations in var1 and var2.
Thank you for your help!
Comment