I have 3 variables (A,B,C) which have 'Yes' or 'No' answers.
Yes = 1 No = 2 I wish to combine the three variables into one variable called D. The variable D should have only 2 values: 1 and 2. 1 = Any case which answered Yes in one of A, B, C. 2 = Any case which answered No in all three variables A or B or C. Ofcourse, cases with missing values in A, or B or C should be deleted. Please help. Thank you, John ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
There are various ways you could do it. Here are a couple ways. I'm assuming you have no missing data on variables A to C.
COMPUTE D = ANY(1,A,B,C). RECODE D (0=2) (ELSE=copy). Another way: COMPUTE D = (SUM(A,B,C) EQ 6) + 1. For the second method, SUM(A,B,C) EQ 6 is true (D=1) when A=B=C=2; SUM(A,B,C) EQ 6 is false (D=0) when at least one of the variables = 1. Adding 1 gets you to the 1-2 coding you want. HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by John-3
Thank you, Bruce.
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Hola!!!! Tal vez te ayude este sintaxis DATASET ACTIVATE Conjunto_de_datos0. ***********************************************************************************************************************************
* Código codificación de variable con 1 si en todas las variables que se recorren son 1 y con 2 si * en alguna variable que recorre es 2 o missing * * Realizado por: Javier Figueroa
* Fecha: Julio 2013 ************************************************************************************************************************************ /*recodifica variable D con 1 si todas las variablas A - C son 1*.
VECTOR VAR_A=A TO C. /* SET DE VARIABLES A. COMPUTE ncuenta=0. - LOOP #J=1 TO 3. - DO IF NOT MISSING(VAR_A(#J)). - COMPUTE F4=0.
- IF VAR_A(#J)=1 F4=1. - DO IF F4=1. - COMPUTE ncuenta=ncuenta+1. - END IF.
- END IF. - END LOOP. - DO IF ncuenta=3. - COMPUTE D=1. - END IF.
- DO IF ncuenta<3. - COMPUTE D=2. - END IF. EXECUTE. Saludos Cordiales, 2013/7/4 John <[hidden email]> Thank you, Bruce. Javier Figueroa Procesamiento y Análisis de bases de datos |
Free forum by Nabble | Edit this page |