This post was updated on .
q1 q2 q3 q4 q5 q6 q7 q8
14 15 16 1 2 20 22 24 I want it to be in order in lines like 1 2 14 15 16 20 22 24 using vector syntax. Please, how? |
Administrator
|
several possibilities take your pick. 1. Use VARSTOCASES followed by SORT followed by building counter index then CASESTOVARS. 2. Create code to do a SORT inline (search archives. I and others have posted such code several times). 3. Read into MATRIX, use GRADE operator by Row in a loop then reorder according to results. 4. There is I believe something in the extended transforms python kit which you again can search the archives. Or Jon will pitch in. --
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
I've made some changes to the question. Can I use your options then?
|
Administrator
|
In reply to this post by David Marso
Here is code for solution 3.
DATA LIST LIST /A1 TO A10. BEGIN DATA 1 3 2 6 5 7 8 2 3 9 4 3 5 6 7 6 8 9 0 2 2 5 6 7 8 3 5 9 2 5 END DATA. MATRIX. GET data / FILE * / VARIABLES A1 TO A10. COMPUTE copy=data. LOOP #=1 TO NROW(data). + COMPUTE X=GRADE(data(#,:)). + LOOP ##=1 TO NCOL(X). + COMPUTE copy(#,x(##))=data(#,##). + END LOOP. END LOOP. PRINT data. PRINT copy. END MATRIX. DATA 1 3 2 6 5 7 8 2 3 9 4 3 5 6 7 6 8 9 0 2 2 5 6 7 8 3 5 9 2 5 COPY 1 2 2 3 3 5 6 7 8 9 0 2 3 4 5 6 6 7 8 9 2 2 3 5 5 5 6 7 8 9
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
maybe there's some solution using vectors instead if matrix comparing each cell with others?
with: count vecq2=q1 to q10 (1 thru 10)..... |
Administrator
|
In reply to this post by Alina
Well, we have NO way of discerning that as you didn't bother to articulate the new question.
--
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
In reply to this post by Alina
-----
Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/vector-codes-in-order-tp5724291p5724297.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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
In reply to this post by Alina
Yes, but count isn't going to help. Look up LOOP and find a sort algorithm and write it. (or search these archives and find previous code written by myself or others).
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
found the right decision. thanks.
http://www.spsstools.net/Syntax/RankingLargestValSortingGrouping/SortingValuesWithinCases_Bubble-Sort.txt |
In reply to this post by Alina
type "SORT VARIABLES."
in a syntax widow. Place your cursor within the text of the
command. Key <f1> if on Windows. IIRC it is <help>
in MACs.
Art Kendall Social Research ConsultantsOn 2/3/2014 5:19 AM, Agatha [via SPSSX Discussion] wrote: vector Q2_1: 14 15 16 1 2 20
Art Kendall
Social Research Consultants |
Administrator
|
Art,
How would this be applicable in the OP's situation? --
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
In reply to this post by Alina
For a small number of variables the bubble sort will probably work fine.
Note however that the MATRIX code doesn't require any hard coded magic numbers to work properly.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
FWIW: Here is code for the first approach I suggested :
DATA LIST LIST /A1 TO A10. BEGIN DATA 1 3 2 6 5 7 8 2 3 9 4 3 5 6 7 6 8 9 0 2 2 5 6 7 8 3 5 9 2 5 END DATA. VARSTOCASES / MAKE x FROM A1 TO A10 /ID=ID . SORT CASES BY ID x. CASESTOVARS ID=ID.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Alina
Using an extension command, you could do
this.
data list list/q2_1 to q2_6 (6f1.0). begin data. 14 15 16 1 2 20 17 18 16 3 2 23 end data. dataset name data. begin program. def sorter(*args): return sorted(args) end program. spssinc trans result = q2_1 to q2_6 /variables q2_1 to q2_6 /formula "sorter(<>)". Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Agatha <[hidden email]> To: [hidden email], Date: 02/03/2014 06:52 AM Subject: [SPSSX-L] vector codes in order Sent by: "SPSSX(r) Discussion" <[hidden email]> vector Q2_1: 14 15 16 1 2 20 vector Q2_2: 17 18 16 3 2 23 I want it to be in order in lines like 1 2 14 15 16 20 using vector syntax. Please, how? -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/vector-codes-in-order-tp5724291.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 |
In reply to this post by David Marso
My mistake!
I looked up SORT VARIABLES in <help> I saw SORT VARIABLES BY VALUES. I misread that. I thought it would sort by the "values". It does NOT it sorts by "value labels". It can only sort all of the variables in a data set. I should have kept reading. Art Kendall Social Research ConsultantsOn 2/3/2014 9:15 AM, David Marso [via SPSSX Discussion] wrote: Art,
Art Kendall
Social Research Consultants |
In reply to this post by Jon K Peck
Hi Jon using your code, the spssinc trans gives me the following warning: The name VARIABLES is not a recognized subcommand. Execution of this command stops. I use the version 1.3.1. What do I do wrong here? TIA Christian ********************************** Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Jon K Peck Using an extension command, you could do this.
|
I think you have an old version of some
of the files on your search path. Run SHOW EXT and see if you can
find multiple copies of SPSSINC_TRANS.xml. The first one on the search
path will be used. The VARIABLES subcommand was added in November,
2012. Of course, the .py file might also be stale.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: "la volta statistics" <[hidden email]> To: Jon K Peck/Chicago/IBM@IBMUS, <[hidden email]>, Date: 02/04/2014 05:31 AM Subject: AW: vector codes in order Hi Jon using your code, the spssinc trans gives me the following warning: The name VARIABLES is not a recognized subcommand. Execution of this command stops. I use the version 1.3.1. What do I do wrong here? TIA Christian ********************************** la volta statistics Christian Schmidhauser, Dr.phil.II Im Gubel 29 CH-8706 Feldmeilen Tel: +41 (043) 233 98 01 Fax: +41 (043) 233 98 02 email: mailto:schmidhauser@... Von: SPSSX(r) Discussion [[hidden email]] Im Auftrag von Jon K Peck Gesendet: Montag, 3. Februar 2014 18:59 An: [hidden email] Betreff: Re: vector codes in order Using an extension command, you could do this. data list list/q2_1 to q2_6 (6f1.0). begin data. 14 15 16 1 2 20 17 18 16 3 2 23 end data. dataset name data. begin program. def sorter(*args): return sorted(args) end program. spssinc trans result = q2_1 to q2_6 /variables q2_1 to q2_6 /formula "sorter(<>)". Jon Peck (no "h") aka Kim Senior Software Engineer, IBM peck@... phone: 720-342-5621 From: Agatha <agatha.kravtsova@...> To: [hidden email], Date: 02/03/2014 06:52 AM Subject: [SPSSX-L] vector codes in order Sent by: "SPSSX(r) Discussion" <[hidden email]> vector Q2_1: 14 15 16 1 2 20 vector Q2_2: 17 18 16 3 2 23 I want it to be in order in lines like 1 2 14 15 16 20 using vector syntax. Please, how? -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/vector-codes-in-order-tp5724291.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (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 |
Free forum by Nabble | Edit this page |