Reputation: 8494
I am a SPSS newbie having trained previously in R and Stata, however some survey data I am working on uses SPSS so I am forced to convert.
I have a relatively simple question - how once I have created a variable, do I then move it after another variable?
For example, I am creating a new variable 'bmi' from height and weight. How do I put this new variable directly after height and weight and not at the end?
COMPUTE bmi=weight/((height/100)*(height/100)).
VARIABLE LABELS bmi 'Calculated BMI'.
EXECUTE.
I don't wish to reorder all my variables, as there is over 500 (and more are being created from other researchers working on the same data).
Thanks in advance.
Upvotes: 3
Views: 9538
Reputation: 5417
You can also reorder variables on the GET command with the KEEP subcommand. If you just need to move a few variables, you can do this by dragging them in the Data Editor Variable View. Also, the SORT VARIABLES command allows you to reorder variables by name, type, or other properties. You can even create a custom attribute for each variable with the intended order and use that in SORT VARIABLES.
Upvotes: 2
Reputation: 2929
You can do this by using the ADD FILES command.
ADD FILES FILE = * /KEEP=ID to Weight BMI ALL.
What the above code assumes is that you have ID
to be the very first variable in your data file and from ID
through to Weight
, these are all retained in their original order. Then you specify BMI
to come next and then any remaning undefined variables from this syntax that exist in the data are all captured under the key word ALL
and will be present in the data files after BMI
.
Upvotes: 2