inparametric.com

GNU/Linux | Behavior | Higher Education | SPSS | Statistics |






Sorting and Rearranging Variables’ Name with SPSS Syntax

27 August, 2007 (18:22) | English, Statistics | By: Bhina Patria | Viewed 752 times


Recently I came across this tricky task: sorting variable name in SPSS Data Editor. It should not be a problem with only few variables, but imagine to do it for a couple hundreds variables! OK maybe I’m not clear enough in explaining this. For example I have a data set with variable name Var001, Var003, and Var002 and I want to order it to Var001, Var002 and Var003.

After googling I found the solution listed here. The syntax command:

FLIP.
SORT CASES BY case_lbl.
FLIP NEWNAMES=case_lbl.

The first command is transposing the data file, this means that all of your variables’ name will be listed in one variable. The second command is sorting the variable. The last one transposing again to its original structure.

However this syntax turns out to be very bad solution. After the first transposing command the variables is losing its variable definition such as variable label, missing value, column etc. This thing happen because each variables turn into a variable value. After digging some more information the solution is quite simple: utilizing save command! The syntax is like so:

SAVE OUTFILE=’C:/test.sav’
/KEEP= var001 var002 var003.

These commands basically save the data set in different order. If you have a lot of variables and you want to sort it alphabetically, just sort your variable list in word processor like Openoffice.org or MS Word.

Comments

Comment from Idetrorce
Time: December 16, 2007, 1:03 am

very interesting, but I don’t agree with you
Idetrorce

Write a comment





:) :( :d :"> :(( \:d/ :x 8-| /:) :o :-? :-" :-w ;) [-( :)>- more »