b***@gmail.com
2019-10-17 20:58:15 UTC
I am de-duplicating a large data set using CASETOVARS.
Because I have up to 24 duplicates in the data set, after I combine, each of my other variables becomes 24 new variables. For example:
The single variable "pregnant" becomes "pregnant.1", "pregnant.2",..."pregnant.24".
I want to recombine these to a single variable so that if any of the variables "pregnant.1" through "pregnant.24" = 1, a new variable pregnant=1 is created. To do this I have to manually write length code like this:
IF ((pregnant.1 = 1) OR (pregnant.2 = 1) OR (pregnant.3 = 1) OR (pregnant.4 = 1) OR (pregnant.5 = 1) OR (pregnant.6 = 1) OR (pregnant.7 = 1) OR (pregnant.8 = 1) OR (pregnant.9 = 1) OR (pregnant.10 = 1.....pregnant.24 = 1)) pregnant = 1.
Every time I run a new dataset, I will have a different number of these new variables, so I am wondering if there is a shorthand to create a new variable like I could do in R.
For example:
IF (pregnant.1:24 = 1) pregnant=1.
Thanks.
Because I have up to 24 duplicates in the data set, after I combine, each of my other variables becomes 24 new variables. For example:
The single variable "pregnant" becomes "pregnant.1", "pregnant.2",..."pregnant.24".
I want to recombine these to a single variable so that if any of the variables "pregnant.1" through "pregnant.24" = 1, a new variable pregnant=1 is created. To do this I have to manually write length code like this:
IF ((pregnant.1 = 1) OR (pregnant.2 = 1) OR (pregnant.3 = 1) OR (pregnant.4 = 1) OR (pregnant.5 = 1) OR (pregnant.6 = 1) OR (pregnant.7 = 1) OR (pregnant.8 = 1) OR (pregnant.9 = 1) OR (pregnant.10 = 1.....pregnant.24 = 1)) pregnant = 1.
Every time I run a new dataset, I will have a different number of these new variables, so I am wondering if there is a shorthand to create a new variable like I could do in R.
For example:
IF (pregnant.1:24 = 1) pregnant=1.
Thanks.