Sure. attached is a sample SAV file. it has an MR Set with 6 dichotumius responses.
the goal here is to transform this set into one variable in which the following are given:
it has 3 categories
1- for respondents who mark '1' in any of q0033_0001, q0033_0002, q0033_0003 variables.
2- for respondents who mark '1' in any of q0033_0004, q0033_0005, q0033_0006 variables.
3- for respondents who mark '1' in both of the previous conditions.
thous transforming the whole set into 3 categories within a single variable. my approach was quick a dirty:
COMPUTE YOUNG_CAT = ANY (1, q0033_0001, q0033_0002, q0033_0003).
COMPUTE MATURE_CAT = ANY (1, q0033_0004, q0033_0004, q0033_0006).
EXECUTE.
IF (YOUNG_CAT=1) AGE_CAT=1.
IF ( MATURE_CAT=1) AGE_CAT=2.
IF ( YOUNG_CAT=1 AND MATURE_CAT=1) AGE_CAT=3.
EXECUTE.
is there a more elegant way to achieve this using DO-REPEAT?
------------------------------
Meni Berger
------------------------------
Original Message:
Sent: Wed December 09, 2020 02:53 PM
From: Jon Peck
Subject: Efficiently creating a single variable from multiple binary variables
Please be more specific about what you want to do.
--
Original Message:
Sent: 12/9/2020 2:43:00 AM
From: Meni Berger
Subject: RE: Efficiently creating a single variable from multiple binary variables
Hello Guru Jon,
I too have recently encountered such an issue last week. although not as many variables were present, none the less a real pain. can you please provide a proper master example of how such a DO REPEAT loop should look like?
thanks!
------------------------------
Meni Berger
Original Message:
Sent: Tue December 08, 2020 12:53 PM
From: Jon Peck
Subject: Efficiently creating a single variable from multiple binary variables
Try a DO REPEAT loop. That allows you to write a COMPUTE or other transformation commands as a template where the loop substitutes the variable names. And if the variables are contiguous, you can use TO to avoid having to list them explicitly. If they are not contiguous but the names match some pattern, the SPSSINC SELECT VARIABLES extension command can create macros covering them.
--
Original Message:
Sent: 12/7/2020 9:40:00 PM
From: Sharon Morris
Subject: Efficiently creating a single variable from multiple binary variables
Hi all,
I have a data file in which many single response questions were asked, but in order to be compatible with accessibility software, had to be asked as a series of binary questions instead of a simple single response question. Thus, my data has been collected in a series of binary variables instead of each question as a single variable.
This has created an extremely inefficient datafile that is difficult for others to use. I would like to collapse all of the binary variables back into single response variables. I know how to do this with syntax, but manually typing this out for every variable in my data file is going to take days and is barely worth the effort.
Is there any way to do this efficiently?
------------------------------
Sharon Morris
------------------------------
#SPSSStatistics