Identifying Top Ranked Concept

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

Identifying Top Ranked Concept

Jim Moffitt
I inherited some data from a survey that asked respondents to rank the
top three concepts from among 11 concepts.

The data are encoded in eleven contiguous columns, one for each concept,
named Q8concept1 to Q8concept11.


I've included a sample data file that can be interpreted as follows.

Respondent 101 thought concept 10 was the best concept so a 1 was placed
in the Q8concept10 column for case 101.

Respondent 101 thought concept 5 was the second best concept so a 2 was
placed in the Q8concept5 column for case 101.

Respondent 101 thought concept 2 was the third best concept so a 3  was
placed in the Q8concept2 column for case 101.

 

I need to create a new variable that identifies in a single variable
which of the 11 concepts was ranked number 1 for each case.

Thus, the new variable will contain a 10 for respondent 101, a 3 for
respondent 102, a 3 for respondent 103, a 5 for respondent 104, and so
forth.

 

I guess I need to create a vector to loop through Q8concept1 to
Q8concept 11 to identify which of those variables contains the minimum
value for each case, but I don't know how to write the code to create
the new variable and place a value of 1 to 11 in it to denote which of
the 11 concepts was ranked number 1.

 

Does anyone know how to write such a macro? Thanks for the help.

 

DATA LIST LIST (",")  / id Q8concept1 to Q8concept11.

BEGIN DATA

101,,3,,,2,,,,,1,,

102,,,1,,,3,,2,,,,

103,2,,1,,,3,,,,,,

104,,,3,,1,,,2,,,,

105,,1,,,,,3,,,,2,

106,,1,,,,,2,,,,3,

107,,,,,3,2,1,,,,,

END DATA.

 
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Top Ranked Concept

Maguin, Eugene
Jim,

You could indeed do this with a vector but you could also do it with a Do
repeat.

With vector.
*  Assuming no missing values!.
Vector Q8=Q8concept1 to Q8concept11.
Loop #i=1 to 11.
+  if (q8(#i) eq 1) topitem=#i.
End loop.


With Do repeat.
Do repeat Q8=Q8concept1 to Q8concept11/
   item=1 2 3 4 5 6 7 8 9 10 11.
+  if (Q8 eq 1) topitem=item.
End repeat.

Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Top Ranked Concept

Jim Moffitt
Thanks, Gene. I used your second suggestion and it worked perfectly.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gene Maguin
Sent: Wednesday, August 01, 2007 10:06 AM
To: [hidden email]
Subject: Re: Identifying Top Ranked Concept

Jim,

You could indeed do this with a vector but you could also do it with a
Do repeat.

With vector.
*  Assuming no missing values!.
Vector Q8=Q8concept1 to Q8concept11.
Loop #i=1 to 11.
+  if (q8(#i) eq 1) topitem=#i.
End loop.


With Do repeat.
Do repeat Q8=Q8concept1 to Q8concept11/
   item=1 2 3 4 5 6 7 8 9 10 11.
+  if (Q8 eq 1) topitem=item.
End repeat.

Gene Maguin