Hi,
I exported data from a survey system. The ranking data looks like this Rank1 Rank2 Rank3 Rank4 Rank5 A D C B E D A B E C B E D C A I want to change the structure of the data to something like the following (Rank1=5 .... Rank5=1) A B C D E 5 5 3 5 4 4 3 2 4 2 1 2 1 3 1 I have see a similar question here suggest to use VECTOR and LOOP. http://spssx-discussion.1045642.n5.nabble.com/Ranking-Question-SPSS-td5709826.html But, I have no idea how to use them. Can anybody please help? |
Use my macro !RANKREV from "Series response tools" collection here:
http://www.spsstools.net/en/KO-spssmacros/
Then recode 1->5, 5->1 etc. 30.06.2017 15:06, sant пишет:
Hi, I exported data from a survey system. The ranking data looks like this Rank1 Rank2 Rank3 Rank4 Rank5 A D C B E D A B E C B E D C A I want to change the structure of the data to something like the following (Rank1=5 .... Rank5=1) A B C D E 5 5 3 5 4 4 3 2 4 2 1 2 1 3 1 I have see a similar question here suggest to use VECTOR and LOOP. http://spssx-discussion.1045642.n5.nabble.com/Ranking-Question-SPSS-td5709826.html But, I have no idea how to use them. Can anybody please help? -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Changing-the-ranking-data-structure-tp5734488.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 ===================== 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 |
Thank you very much. I could do it.
|
Administrator
|
In reply to this post by sant
Does the following code give the result you're looking for?
* Read in the data. NEW FILE. DATASET CLOSE ALL. DATA LIST LIST / Rank1 TO Rank5 (5A1). BEGIN DATA A D C B E D A B E C B E D C A END DATA. VARSTOCASES /ID=id /MAKE Rank FROM Rank1 TO Rank5 /INDEX=i(5) /NULL=KEEP. SORT CASES BY id Rank. COMPUTE i = 6-i. /* Reverse-code i. CASESTOVARS /ID=id /INDEX=Rank /GROUPBY=VARIABLE. FORMATS A to E (F1). LIST A to E.
--
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/). |
I believe the OP actually displays an aggregated result as original cases are not preserved (every Rank is sorted). If so, a simple CROSSTAB would display the distribution. There are only 3 demo cases ans no ties.
/PR * Read in the data. NEW FILE. DATASET CLOSE ALL. DATA LIST LIST / Rank1 TO Rank5 (5A1). BEGIN DATA A D C B E D A B E C B E D C A END DATA. VARSTOCASES /MAKE Rank FROM Rank1 TO Rank5 /INDEX=i(5) /NULL=KEEP. COMPUTE i = 6-i. /* Reverse-code i. *Summarize rankings in table *. CROSSTABS /TABLES=i BY Rank /FORMAT=DVALUE TABLES /CELLS =COUNT /COUNT ROUND CELL . *Continue to transform data to OP spec:s. NumberOfCases could be calculated with AGGREGATE: *. *Generate new 'case id numbers' *. SORT CASES BY Rank(A) i(D). COMPUTE #NumberOfCases = 3. COMPUTE id = MOD($casenum-1, #NumberOfCases)+1. *Return to wide format*. SORT CASES BY id(A) Rank(A). CASESTOVARS /ID=id /INDEX=Rank /GROUPBY=VARIABLE . *Rows are not original cases anymore*. DELETE VARIABLES id . FORMATS A to E (F1). LIST A to E.
|
Free forum by Nabble | Edit this page |