Consolidating Data

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Consolidating Data

Jim Moffitt
I have inherited a data file that will require me to consolidate some
variables.
 
I've provided some syntax at the end of  this message that will generate
a sample data file.
 
The data was generated by a questionnaire that presented a list of
cities and asked respondents to identify the cities they have visited
within the last 18 months.
 
The city data was captured in a series of contiguous columns exemplified
by variables q_1.1 to q_1.4 in the sample data file.
 
If the respondent has visited Miami, there is a 1 in q_1.1. If not,
q_1.1 is system missing.
If the respondent has visited St. Pete, there is a 2 in q_1.2. If not,
q_1.2 is system missing.
If the respondent has visited Hilton Head, there is a 3 in q_1.3. If
not, q_1.3 is system missing.
If the respondent has visited Hatteras, there is a 4 in q_1.4. If not,
q_1.4 is system missing.
 
Each respondent who had visited a city was asked three questions about
their trip to that city.
How did you get there?
How long did you stay?
Where did you stay?
 
These question are grouped contiguously for each city.
 
How did you get there? (Miami) is q_2.1.
How long did you stay? (Miami) is q_3.1.
Where did you stay? (Miami) is q_4.1.
How did you get there? (St. Pete) is q_2.2.
How long did you stay? (St. Pete) is q_3.2.
Where did you stay? (St. Pete) is q_4.2.
How did you get there? (Hilton Head) q_2.3.
How long did you stay? (Hilton Head) q_3.3.
Where did you stay? (Hilton Head) q_4.3.
How did you get there? (Hatteras) q_2.4.
How long did you stay? (Hilton Head) q_3.4.
Where did you stay? (Hilton Head) q_4.4.
 
The sample data file has data for 9 respondents.
The respondents, made 16 trips in total (Sum the last variable in the
data file, TotVisits).
 
I'm trying to consolidate the transportation questions (q_2.1, q_2.2,
q_2.3, and q_2.4) to determine how many of the 16 total visits involved
each mode of transportation.
I'm trying to consolidate the duration questions (q_3.1, q_3.2, q_3.3,
and q_3.4) to determine how many of the 16 total visits involved each
duration category.
I'm trying to consolidate the accommodation questions (q_4.1, q_4.2,
q_4.3, and q_4.4) to determine how many of the 16 total visits involved
each type of accommodation.
 
There is a missing value issue that involves the fact that anyone who
visited a city should have answered all three questions about that city.
Some respondents didn't as exemplified by the fact that case 109 has a
system missing value for q_3.1 (Miami/duration).
 
I think I have to do a conditional test to assure that each respondent
that visited a city has a response for each of the 3 questions
pertaining to that city. If they don't, I think I want to insert a
user-defined missing value of -99. I'm not sure how to do this.
 
I'm also unsure how to consolidate the transportation, duration and
accommodation questions.
 
Can anyone show me how this is done?
 
Thanks for the help.
 
Here's my admittedly inelegant sample data.
 
DATA LIST LIST (",") / id q_1.1 q_1.2 q_1.3 q_1.4 q_2.1 q_3.1
q_4.1 q_2.2 q_3.2 q_4.2 q_2.3 q_3.3 q_4.3 q_2.4 q_3.4 q_4.4.
BEGIN DATA
101,1,2,3,,2,1,1,1,1,1,2,2,2,,,,
102,,,,4,,,,,,,,,,2,3,2,
103,1,,,,2,2,2,,,,,,,,,,
104,1,,3,,3,3,3,,,,2,3,2,,,,
105,1,2,,4,1,4,1,2,1,2,,,,1,1,1,
106,,,,,,,,,,,,,,,,,
107,1,,,,4,4,3,,,,,,,,,,
108,,2,3,,,,,3,4,1,2,4,2,,,,
109,1,,3,4,2,,1,,,,3,1,1,3,3,3,
END DATA.
FORMAT id (f3.0) q_1.1 TO q_4.4 (f1.0).
VARIABLE LABELS
q_1.1 Miami
q_1.2 St. Pete
q_1.3 Hilton Head
q_1.4 Hatteras
q_2.1 How did you get there? (Miami)
q_3.1 How long did you stay? (Miami)
q_4.1 Where did you stay? (Miami)
q_2.2 How did you get there? (St. Pete)
q_3.2 How long did you stay? (St. Pete)
q_4.2 Where did you stay? (St. Pete)
q_2.3 How did you get there? (Hilton Head)
q_3.3 How long did you stay? (Hilton Head)
q_4.3 Where did you stay? (Hilton Head)
q_2.4 How did you get there? (Hatteras)
q_3.4 How long did you stay? (Hatteras)
q_4.4 Where did you stay? (Hatteras).
VALUE LABELS q_1.1 1 Miami
/q_1.2 2 St. Pete
/q_1.3 3 Hilton Head
/q_1.3 3 Hilton Head
/q_1.4 4 Hatteras
/q_2.1 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.2 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.3 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.4 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_3.1 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.2 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.3 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.4 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_4.1 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.2 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.3 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.4 1 'Prvt. Home' 2 'Hotel' 3 'Other'.
COUNT TotVisits= q_1.1 to q_1.4 (1 thru 4).
EXECUTE.
 
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Consolidating Data

Oliver Paula
-----------------------------------------------------------------------
oliver de paula
Eu estarei ausente do Escritorio até 22/11/2006.



========================================================================================================
Este e-mail e confidencial e pode conter informacoes privilegiadas. Se voce nao for o destinatario desta
mensagem por favor delete-a e me informe no endereco acima. Nao copie ou reenvie de forma a revelar estas
informacoes a outras pessoas ou utilize-as para qualquer proposito.

This e-mail is confidential and may also be privileged. If you are not intended recipient, please delete it
and notify me immediately at above address; do not copy, forward or other side disclose the contents of this
e-mail to any other person or use it for any purpose.
Reply | Threaded
Open this post in threaded view
|

Re: Consolidating Data

Marks, Jim
In reply to this post by Jim Moffitt
Jim:

Here is a solution of the tedious variety-- I copied /pasted / edited
the syntax to accommodate the variables you specified. (I'm guessing you
are looking for something more automated, with a longer set of variables
to work through? I usually just slog through-- its faster and more
reliable for me than experimenting.)

FWIW I don't think you need the user missing values to use the COUNT
command.

DO IF q_1.1 GT 0.
RECODE q_2.1 TO q_4.1 (sysmis = -99).
END IF.

DO IF q_1.2 GT 0.
RECODE q_2.2 TO q_4.2 (sysmis = -99).
END IF.

DO IF q_1.3 GT 0.
RECODE q_2.3 TO q_4.3 (sysmis = -99).
END IF.

DO IF q_1.4 GT 0.
RECODE q_2.4 TO q_4.4 (sysmis = -99).
END IF.

MISSING VALUE q_2.1 TO q_4.4 (-99).

COUNT bycar= q_2.1 q_2.2 q_2.3 q_2.4 (1).
COUNT byplane= q_2.1 q_2.2 q_2.3 q_2.4 (2).
COUNT bybus= q_2.1 q_2.2 q_2.3 q_2.4 (3).
COUNT byother= q_2.1 q_2.2 q_2.3 q_2.4 (4).


COUNT days2= q_3.1 q_3.2 q_3.3 q_3.4 (1).
COUNT days7= q_3.1 q_3.2 q_3.3 q_3.4 (2).
COUNT days14= q_3.1 q_3.2 q_3.3 q_3.4 (3).
COUNT days15= q_3.1 q_3.2 q_3.3 q_3.4 (4).

COUNT pvthome= q_4.1 q_4.2 q_4.3 q_4.4 (1).
COUNT hotel= q_4.1 q_4.2 q_4.3 q_4.4 (2).
COUNT other= q_4.1 q_4.2 q_4.3 q_4.4 (3).
exe.


--jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Jim Moffitt
Sent: Thursday, November 16, 2006 5:21 PM
To: [hidden email]
Subject: Consolidating Data

I have inherited a data file that will require me to consolidate some
variables.

I've provided some syntax at the end of  this message that will generate
a sample data file.

The data was generated by a questionnaire that presented a list of
cities and asked respondents to identify the cities they have visited
within the last 18 months.

The city data was captured in a series of contiguous columns exemplified
by variables q_1.1 to q_1.4 in the sample data file.

If the respondent has visited Miami, there is a 1 in q_1.1. If not,
q_1.1 is system missing.
If the respondent has visited St. Pete, there is a 2 in q_1.2. If not,
q_1.2 is system missing.
If the respondent has visited Hilton Head, there is a 3 in q_1.3. If
not, q_1.3 is system missing.
If the respondent has visited Hatteras, there is a 4 in q_1.4. If not,
q_1.4 is system missing.

Each respondent who had visited a city was asked three questions about
their trip to that city.
How did you get there?
How long did you stay?
Where did you stay?

These question are grouped contiguously for each city.

How did you get there? (Miami) is q_2.1.
How long did you stay? (Miami) is q_3.1.
Where did you stay? (Miami) is q_4.1.
How did you get there? (St. Pete) is q_2.2.
How long did you stay? (St. Pete) is q_3.2.
Where did you stay? (St. Pete) is q_4.2.
How did you get there? (Hilton Head) q_2.3.
How long did you stay? (Hilton Head) q_3.3.
Where did you stay? (Hilton Head) q_4.3.
How did you get there? (Hatteras) q_2.4.
How long did you stay? (Hilton Head) q_3.4.
Where did you stay? (Hilton Head) q_4.4.

The sample data file has data for 9 respondents.
The respondents, made 16 trips in total (Sum the last variable in the
data file, TotVisits).

I'm trying to consolidate the transportation questions (q_2.1, q_2.2,
q_2.3, and q_2.4) to determine how many of the 16 total visits involved
each mode of transportation.
I'm trying to consolidate the duration questions (q_3.1, q_3.2, q_3.3,
and q_3.4) to determine how many of the 16 total visits involved each
duration category.
I'm trying to consolidate the accommodation questions (q_4.1, q_4.2,
q_4.3, and q_4.4) to determine how many of the 16 total visits involved
each type of accommodation.

There is a missing value issue that involves the fact that anyone who
visited a city should have answered all three questions about that city.
Some respondents didn't as exemplified by the fact that case 109 has a
system missing value for q_3.1 (Miami/duration).

I think I have to do a conditional test to assure that each respondent
that visited a city has a response for each of the 3 questions
pertaining to that city. If they don't, I think I want to insert a
user-defined missing value of -99. I'm not sure how to do this.

I'm also unsure how to consolidate the transportation, duration and
accommodation questions.

Can anyone show me how this is done?

Thanks for the help.

Here's my admittedly inelegant sample data.

DATA LIST LIST (",") / id q_1.1 q_1.2 q_1.3 q_1.4 q_2.1 q_3.1
q_4.1 q_2.2 q_3.2 q_4.2 q_2.3 q_3.3 q_4.3 q_2.4 q_3.4 q_4.4.
BEGIN DATA
101,1,2,3,,2,1,1,1,1,1,2,2,2,,,,
102,,,,4,,,,,,,,,,2,3,2,
103,1,,,,2,2,2,,,,,,,,,,
104,1,,3,,3,3,3,,,,2,3,2,,,,
105,1,2,,4,1,4,1,2,1,2,,,,1,1,1,
106,,,,,,,,,,,,,,,,,
107,1,,,,4,4,3,,,,,,,,,,
108,,2,3,,,,,3,4,1,2,4,2,,,,
109,1,,3,4,2,,1,,,,3,1,1,3,3,3,
END DATA.
FORMAT id (f3.0) q_1.1 TO q_4.4 (f1.0).
VARIABLE LABELS
q_1.1 Miami
q_1.2 St. Pete
q_1.3 Hilton Head
q_1.4 Hatteras
q_2.1 How did you get there? (Miami)
q_3.1 How long did you stay? (Miami)
q_4.1 Where did you stay? (Miami)
q_2.2 How did you get there? (St. Pete)
q_3.2 How long did you stay? (St. Pete)
q_4.2 Where did you stay? (St. Pete)
q_2.3 How did you get there? (Hilton Head)
q_3.3 How long did you stay? (Hilton Head)
q_4.3 Where did you stay? (Hilton Head)
q_2.4 How did you get there? (Hatteras)
q_3.4 How long did you stay? (Hatteras)
q_4.4 Where did you stay? (Hatteras).
VALUE LABELS q_1.1 1 Miami
/q_1.2 2 St. Pete
/q_1.3 3 Hilton Head
/q_1.3 3 Hilton Head
/q_1.4 4 Hatteras
/q_2.1 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.2 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.3 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.4 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_3.1 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.2 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.3 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.4 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_4.1 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.2 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.3 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.4 1 'Prvt. Home' 2 'Hotel' 3 'Other'.
COUNT TotVisits= q_1.1 to q_1.4 (1 thru 4).
EXECUTE.
Reply | Threaded
Open this post in threaded view
|

Re: Consolidating Data

Beadle, ViAnn
In reply to this post by Jim Moffitt
Have you thought about treating these as multiple response items. Q_1.1, q_1.2, etc. look suspiciously like multiple dichotomies whereas the transportation questions look like multiple response groups. You'll need Custom Tables to do this which is an option to the base.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jim Moffitt
Sent: Thursday, November 16, 2006 5:21 PM
To: [hidden email]
Subject: Consolidating Data

I have inherited a data file that will require me to consolidate some
variables.

I've provided some syntax at the end of  this message that will generate
a sample data file.

The data was generated by a questionnaire that presented a list of
cities and asked respondents to identify the cities they have visited
within the last 18 months.

The city data was captured in a series of contiguous columns exemplified
by variables q_1.1 to q_1.4 in the sample data file.

If the respondent has visited Miami, there is a 1 in q_1.1. If not,
q_1.1 is system missing.
If the respondent has visited St. Pete, there is a 2 in q_1.2. If not,
q_1.2 is system missing.
If the respondent has visited Hilton Head, there is a 3 in q_1.3. If
not, q_1.3 is system missing.
If the respondent has visited Hatteras, there is a 4 in q_1.4. If not,
q_1.4 is system missing.

Each respondent who had visited a city was asked three questions about
their trip to that city.
How did you get there?
How long did you stay?
Where did you stay?

These question are grouped contiguously for each city.

How did you get there? (Miami) is q_2.1.
How long did you stay? (Miami) is q_3.1.
Where did you stay? (Miami) is q_4.1.
How did you get there? (St. Pete) is q_2.2.
How long did you stay? (St. Pete) is q_3.2.
Where did you stay? (St. Pete) is q_4.2.
How did you get there? (Hilton Head) q_2.3.
How long did you stay? (Hilton Head) q_3.3.
Where did you stay? (Hilton Head) q_4.3.
How did you get there? (Hatteras) q_2.4.
How long did you stay? (Hilton Head) q_3.4.
Where did you stay? (Hilton Head) q_4.4.

The sample data file has data for 9 respondents.
The respondents, made 16 trips in total (Sum the last variable in the
data file, TotVisits).

I'm trying to consolidate the transportation questions (q_2.1, q_2.2,
q_2.3, and q_2.4) to determine how many of the 16 total visits involved
each mode of transportation.
I'm trying to consolidate the duration questions (q_3.1, q_3.2, q_3.3,
and q_3.4) to determine how many of the 16 total visits involved each
duration category.
I'm trying to consolidate the accommodation questions (q_4.1, q_4.2,
q_4.3, and q_4.4) to determine how many of the 16 total visits involved
each type of accommodation.

There is a missing value issue that involves the fact that anyone who
visited a city should have answered all three questions about that city.
Some respondents didn't as exemplified by the fact that case 109 has a
system missing value for q_3.1 (Miami/duration).

I think I have to do a conditional test to assure that each respondent
that visited a city has a response for each of the 3 questions
pertaining to that city. If they don't, I think I want to insert a
user-defined missing value of -99. I'm not sure how to do this.

I'm also unsure how to consolidate the transportation, duration and
accommodation questions.

Can anyone show me how this is done?

Thanks for the help.

Here's my admittedly inelegant sample data.

DATA LIST LIST (",") / id q_1.1 q_1.2 q_1.3 q_1.4 q_2.1 q_3.1
q_4.1 q_2.2 q_3.2 q_4.2 q_2.3 q_3.3 q_4.3 q_2.4 q_3.4 q_4.4.
BEGIN DATA
101,1,2,3,,2,1,1,1,1,1,2,2,2,,,,
102,,,,4,,,,,,,,,,2,3,2,
103,1,,,,2,2,2,,,,,,,,,,
104,1,,3,,3,3,3,,,,2,3,2,,,,
105,1,2,,4,1,4,1,2,1,2,,,,1,1,1,
106,,,,,,,,,,,,,,,,,
107,1,,,,4,4,3,,,,,,,,,,
108,,2,3,,,,,3,4,1,2,4,2,,,,
109,1,,3,4,2,,1,,,,3,1,1,3,3,3,
END DATA.
FORMAT id (f3.0) q_1.1 TO q_4.4 (f1.0).
VARIABLE LABELS
q_1.1 Miami
q_1.2 St. Pete
q_1.3 Hilton Head
q_1.4 Hatteras
q_2.1 How did you get there? (Miami)
q_3.1 How long did you stay? (Miami)
q_4.1 Where did you stay? (Miami)
q_2.2 How did you get there? (St. Pete)
q_3.2 How long did you stay? (St. Pete)
q_4.2 Where did you stay? (St. Pete)
q_2.3 How did you get there? (Hilton Head)
q_3.3 How long did you stay? (Hilton Head)
q_4.3 Where did you stay? (Hilton Head)
q_2.4 How did you get there? (Hatteras)
q_3.4 How long did you stay? (Hatteras)
q_4.4 Where did you stay? (Hatteras).
VALUE LABELS q_1.1 1 Miami
/q_1.2 2 St. Pete
/q_1.3 3 Hilton Head
/q_1.3 3 Hilton Head
/q_1.4 4 Hatteras
/q_2.1 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.2 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.3 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.4 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_3.1 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.2 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.3 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.4 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_4.1 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.2 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.3 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.4 1 'Prvt. Home' 2 'Hotel' 3 'Other'.
COUNT TotVisits= q_1.1 to q_1.4 (1 thru 4).
EXECUTE.
Reply | Threaded
Open this post in threaded view
|

Obtaining diversity indices in SPSS

benard nyakundi
Dear All,

I wish to know if it is possible to calculate diversity indeces in SPSS.

Thanks for any help.

Regards

Benard Nyakundi

Center for Data Analysis - Kenya


---------------------------------
Everyone is raving about the all-new Yahoo! Mail beta.
Reply | Threaded
Open this post in threaded view
|

Re: Consolidating Data

Jim Moffitt
In reply to this post by Marks, Jim
Jim:
Thanks for your help. This is exactly what I needed.
Jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Marks, Jim
Sent: Thursday, November 16, 2006 6:01 PM
To: [hidden email]
Subject: Re: Consolidating Data

Jim:

Here is a solution of the tedious variety-- I copied /pasted / edited
the syntax to accommodate the variables you specified. (I'm guessing you
are looking for something more automated, with a longer set of variables
to work through? I usually just slog through-- its faster and more
reliable for me than experimenting.)

FWIW I don't think you need the user missing values to use the COUNT
command.

DO IF q_1.1 GT 0.
RECODE q_2.1 TO q_4.1 (sysmis = -99).
END IF.

DO IF q_1.2 GT 0.
RECODE q_2.2 TO q_4.2 (sysmis = -99).
END IF.

DO IF q_1.3 GT 0.
RECODE q_2.3 TO q_4.3 (sysmis = -99).
END IF.

DO IF q_1.4 GT 0.
RECODE q_2.4 TO q_4.4 (sysmis = -99).
END IF.

MISSING VALUE q_2.1 TO q_4.4 (-99).

COUNT bycar= q_2.1 q_2.2 q_2.3 q_2.4 (1).
COUNT byplane= q_2.1 q_2.2 q_2.3 q_2.4 (2).
COUNT bybus= q_2.1 q_2.2 q_2.3 q_2.4 (3).
COUNT byother= q_2.1 q_2.2 q_2.3 q_2.4 (4).


COUNT days2= q_3.1 q_3.2 q_3.3 q_3.4 (1).
COUNT days7= q_3.1 q_3.2 q_3.3 q_3.4 (2).
COUNT days14= q_3.1 q_3.2 q_3.3 q_3.4 (3).
COUNT days15= q_3.1 q_3.2 q_3.3 q_3.4 (4).

COUNT pvthome= q_4.1 q_4.2 q_4.3 q_4.4 (1).
COUNT hotel= q_4.1 q_4.2 q_4.3 q_4.4 (2).
COUNT other= q_4.1 q_4.2 q_4.3 q_4.4 (3).
exe.


--jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Jim Moffitt
Sent: Thursday, November 16, 2006 5:21 PM
To: [hidden email]
Subject: Consolidating Data

I have inherited a data file that will require me to consolidate some
variables.

I've provided some syntax at the end of  this message that will generate
a sample data file.

The data was generated by a questionnaire that presented a list of
cities and asked respondents to identify the cities they have visited
within the last 18 months.

The city data was captured in a series of contiguous columns exemplified
by variables q_1.1 to q_1.4 in the sample data file.

If the respondent has visited Miami, there is a 1 in q_1.1. If not,
q_1.1 is system missing.
If the respondent has visited St. Pete, there is a 2 in q_1.2. If not,
q_1.2 is system missing.
If the respondent has visited Hilton Head, there is a 3 in q_1.3. If
not, q_1.3 is system missing.
If the respondent has visited Hatteras, there is a 4 in q_1.4. If not,
q_1.4 is system missing.

Each respondent who had visited a city was asked three questions about
their trip to that city.
How did you get there?
How long did you stay?
Where did you stay?

These question are grouped contiguously for each city.

How did you get there? (Miami) is q_2.1.
How long did you stay? (Miami) is q_3.1.
Where did you stay? (Miami) is q_4.1.
How did you get there? (St. Pete) is q_2.2.
How long did you stay? (St. Pete) is q_3.2.
Where did you stay? (St. Pete) is q_4.2.
How did you get there? (Hilton Head) q_2.3.
How long did you stay? (Hilton Head) q_3.3.
Where did you stay? (Hilton Head) q_4.3.
How did you get there? (Hatteras) q_2.4.
How long did you stay? (Hilton Head) q_3.4.
Where did you stay? (Hilton Head) q_4.4.

The sample data file has data for 9 respondents.
The respondents, made 16 trips in total (Sum the last variable in the
data file, TotVisits).

I'm trying to consolidate the transportation questions (q_2.1, q_2.2,
q_2.3, and q_2.4) to determine how many of the 16 total visits involved
each mode of transportation.
I'm trying to consolidate the duration questions (q_3.1, q_3.2, q_3.3,
and q_3.4) to determine how many of the 16 total visits involved each
duration category.
I'm trying to consolidate the accommodation questions (q_4.1, q_4.2,
q_4.3, and q_4.4) to determine how many of the 16 total visits involved
each type of accommodation.

There is a missing value issue that involves the fact that anyone who
visited a city should have answered all three questions about that city.
Some respondents didn't as exemplified by the fact that case 109 has a
system missing value for q_3.1 (Miami/duration).

I think I have to do a conditional test to assure that each respondent
that visited a city has a response for each of the 3 questions
pertaining to that city. If they don't, I think I want to insert a
user-defined missing value of -99. I'm not sure how to do this.

I'm also unsure how to consolidate the transportation, duration and
accommodation questions.

Can anyone show me how this is done?

Thanks for the help.

Here's my admittedly inelegant sample data.

DATA LIST LIST (",") / id q_1.1 q_1.2 q_1.3 q_1.4 q_2.1 q_3.1
q_4.1 q_2.2 q_3.2 q_4.2 q_2.3 q_3.3 q_4.3 q_2.4 q_3.4 q_4.4.
BEGIN DATA
101,1,2,3,,2,1,1,1,1,1,2,2,2,,,,
102,,,,4,,,,,,,,,,2,3,2,
103,1,,,,2,2,2,,,,,,,,,,
104,1,,3,,3,3,3,,,,2,3,2,,,,
105,1,2,,4,1,4,1,2,1,2,,,,1,1,1,
106,,,,,,,,,,,,,,,,,
107,1,,,,4,4,3,,,,,,,,,,
108,,2,3,,,,,3,4,1,2,4,2,,,,
109,1,,3,4,2,,1,,,,3,1,1,3,3,3,
END DATA.
FORMAT id (f3.0) q_1.1 TO q_4.4 (f1.0).
VARIABLE LABELS
q_1.1 Miami
q_1.2 St. Pete
q_1.3 Hilton Head
q_1.4 Hatteras
q_2.1 How did you get there? (Miami)
q_3.1 How long did you stay? (Miami)
q_4.1 Where did you stay? (Miami)
q_2.2 How did you get there? (St. Pete)
q_3.2 How long did you stay? (St. Pete)
q_4.2 Where did you stay? (St. Pete)
q_2.3 How did you get there? (Hilton Head)
q_3.3 How long did you stay? (Hilton Head)
q_4.3 Where did you stay? (Hilton Head)
q_2.4 How did you get there? (Hatteras)
q_3.4 How long did you stay? (Hatteras)
q_4.4 Where did you stay? (Hatteras).
VALUE LABELS q_1.1 1 Miami
/q_1.2 2 St. Pete
/q_1.3 3 Hilton Head
/q_1.3 3 Hilton Head
/q_1.4 4 Hatteras
/q_2.1 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.2 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.3 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_2.4 1 'Car' 2 'Plane' 3 'Bus' 4 'Other'
/q_3.1 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.2 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.3 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_3.4 1 '2 Days or Less' 2 '3 to 7 Days' 3 '8 to 14 Days' 4 'More than
14 Days'
/q_4.1 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.2 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.3 1 'Prvt. Home' 2 'Hotel' 3 'Other'
/q_4.4 1 'Prvt. Home' 2 'Hotel' 3 'Other'.
COUNT TotVisits= q_1.1 to q_1.4 (1 thru 4).
EXECUTE.