Search code examples
spss

Reorder variable in SPSS


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.


Solution

  • 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.