|
Assuming you are using syntax to create the file (ie read a source file
and convert to a SAV file), you can reorder the variables in the VARIABLE LIST and rerun the job that creates it. In general, though, the order of variables in a file is of little importance other than to visually examine the data. Once the file has been created (and especially for files with many fields), you can use LIST to view selected fields for selected records. For example: TEMPORARY . SELECT IF (Var1>100 and Var10<2000) . LIST Var1 Var10 Var5 /Cases=20 . -----Original Message----- From: Jean Hanson [mailto:[hidden email]] Sent: Thursday, August 23, 2007 7:19 PM Subject: Ordering of Variables Hello Listers, Is it possible through syntax to sort the variables in a particular order? If so, could someone point me in the right direction? Thank you, Jean Hanson |
|
Hi Jean,
You can find a macro to do this under this link: http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0708&L=spssx-l&P=R28900&X=70865F4AA72E26FEF8&Y=georg.maubach@... Best regards Georg Maubach Research Manager -----Ursprüngliche Nachricht----- Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Dennis Deck Gesendet: Freitag, 31. August 2007 18:47 An: [hidden email] Betreff: Re: Ordering of Variables Assuming you are using syntax to create the file (ie read a source file and convert to a SAV file), you can reorder the variables in the VARIABLE LIST and rerun the job that creates it. In general, though, the order of variables in a file is of little importance other than to visually examine the data. Once the file has been created (and especially for files with many fields), you can use LIST to view selected fields for selected records. For example: TEMPORARY . SELECT IF (Var1>100 and Var10<2000) . LIST Var1 Var10 Var5 /Cases=20 . -----Original Message----- From: Jean Hanson [mailto:[hidden email]] Sent: Thursday, August 23, 2007 7:19 PM Subject: Ordering of Variables Hello Listers, Is it possible through syntax to sort the variables in a particular order? If so, could someone point me in the right direction? Thank you, Jean Hanson |
|
Jean,
If you want to sort ALL your variables in a particular order, say ASCENDING for example, double-flip (or double-transpose) your DATA set. Here's a sample code. Submit it one at a time to see its effect. Best regards, Florio *Say you want to reorder your variables so that it will be in alphabetical order instead of A D B C E: DATA LIST FREE/A D B C E. BEGIN DATA. 1 1 2 3 1 2 3 4 1 2 END DATA. FLIP VARIABLES=ALL. SORT CASES BY CASE_LBL (A) . FLIP VARIABLES=var001 var002 /NEWNAME=CASE_LBL . DELETE VAR CASE_LBL. Explanation: The first FLIP command transposes the data and creates a CASE_LBL variable whose values are original variable names. Alternatively you can replace the keyword ALL with the variables names in the order that you want in the FLIP command so you do not have to SORT them. For example: FLIP VARIABLES=a b c d e . The SORT command sorts the CASE_LBL variable in Ascending order. The second flip transposes the data back to its original form. The NEWNAMES subcommand uses the values of the CASE_LBL variable as the variable names. At 01:27 PM 8/31/2007, Georg Maubach wrote: >Hi Jean, > >You can find a macro to do this under this link: > >http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0708&L=spssx-l&P=R28900&X=70865F4AA72E26FEF8&Y=georg.maubach@... > >Best regards > >Georg Maubach >Research Manager > >-----Ursprüngliche Nachricht----- >Von: SPSSX(r) Discussion >[mailto:[hidden email]] Im Auftrag von Dennis Deck >Gesendet: Freitag, 31. August 2007 18:47 >An: [hidden email] >Betreff: Re: Ordering of Variables > >Assuming you are using syntax to create the file >(ie read a source file and convert to a SAV >file), you can reorder the variables in the >VARIABLE LIST and rerun the job that creates it. > >In general, though, the order of variables in a >file is of little importance other than to >visually examine the data. Once the file has >been created (and especially for files with many >fields), you can use LIST to view selected >fields for selected records. For example: > >TEMPORARY . >SELECT IF (Var1>100 and Var10<2000) . >LIST Var1 Var10 Var5 /Cases=20 . > > >-----Original Message----- >From: Jean Hanson [mailto:[hidden email]] >Sent: Thursday, August 23, 2007 7:19 PM >Subject: Ordering of Variables > >Hello Listers, >Is it possible through syntax to sort the >variables in a particular order? If so, could >someone point me in the right direction? >Thank you, >Jean Hanson |
|
This is a new feature of SPSS 16. There is a
SORT VARIABLES command. Besides the names, you can sort by the labels, the type, and other properties. Regards, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Florio Arguillas Sent: Friday, August 31, 2007 3:26 PM To: [hidden email] Subject: Re: [SPSSX-L] AW: Re: Ordering of Variables Jean, If you want to sort ALL your variables in a particular order, say ASCENDING for example, double-flip (or double-transpose) your DATA set. Here's a sample code. Submit it one at a time to see its effect. Best regards, Florio *Say you want to reorder your variables so that it will be in alphabetical order instead of A D B C E: DATA LIST FREE/A D B C E. BEGIN DATA. 1 1 2 3 1 2 3 4 1 2 END DATA. FLIP VARIABLES=ALL. SORT CASES BY CASE_LBL (A) . FLIP VARIABLES=var001 var002 /NEWNAME=CASE_LBL . DELETE VAR CASE_LBL. Explanation: The first FLIP command transposes the data and creates a CASE_LBL variable whose values are original variable names. Alternatively you can replace the keyword ALL with the variables names in the order that you want in the FLIP command so you do not have to SORT them. For example: FLIP VARIABLES=a b c d e . The SORT command sorts the CASE_LBL variable in Ascending order. The second flip transposes the data back to its original form. The NEWNAMES subcommand uses the values of the CASE_LBL variable as the variable names. At 01:27 PM 8/31/2007, Georg Maubach wrote: >Hi Jean, > >You can find a macro to do this under this link: > >http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0708&L=spssx-l&P=R28900&X=70865F4AA72E26FEF8&Y=georg.maubach@... > >Best regards > >Georg Maubach >Research Manager > >-----Ursprüngliche Nachricht----- >Von: SPSSX(r) Discussion >[mailto:[hidden email]] Im Auftrag von Dennis Deck >Gesendet: Freitag, 31. August 2007 18:47 >An: [hidden email] >Betreff: Re: Ordering of Variables > >Assuming you are using syntax to create the file >(ie read a source file and convert to a SAV >file), you can reorder the variables in the >VARIABLE LIST and rerun the job that creates it. > >In general, though, the order of variables in a >file is of little importance other than to >visually examine the data. Once the file has >been created (and especially for files with many >fields), you can use LIST to view selected >fields for selected records. For example: > >TEMPORARY . >SELECT IF (Var1>100 and Var10<2000) . >LIST Var1 Var10 Var5 /Cases=20 . > > >-----Original Message----- >From: Jean Hanson [mailto:[hidden email]] >Sent: Thursday, August 23, 2007 7:19 PM >Subject: Ordering of Variables > >Hello Listers, >Is it possible through syntax to sort the >variables in a particular order? If so, could >someone point me in the right direction? >Thank you, >Jean Hanson |
| Free forum by Nabble | Edit this page |
