On Thu, 17 Oct 2019 13:58:15 -0700 (PDT),
[email protected] wrote:
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.
compute pregnant= any(1, pregnant.1 to pregnant.24).
ANY( ) compares the first argument to the remaining list.
ANY( ) returns 0 or 1 for No or Yes.
It is also used for checking multiple values for one variable,
like
compute anyodd= ANY(varxxx, 1, 3, 5, 7, 9) .
https://www.spss-tutorials.com/spss-any-function/
--
Rich Ulrich
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)