Hi,
I am trying to create a variable in the following way:
gen x=(y==1|y==2|y==3)
However, there are many different things that y can equal where x should =1. Is there a more efficient way to do this? Something like gen x=1 if y in the list (1,2,3,4,5,6,7,....) etc? Thanks.
I am trying to create a variable in the following way:
gen x=(y==1|y==2|y==3)
However, there are many different things that y can equal where x should =1. Is there a more efficient way to do this? Something like gen x=1 if y in the list (1,2,3,4,5,6,7,....) etc? Thanks.
Code:
gen nonhosp_detox_rehab=(service_code=="H2034" | service_code=="H0013" | service_code=="H0012" | service_code=="H0012-TG" | service_code=="H2036")
Comment