Using SPSS and PASW/Moving Variables

It is sometimes the case that you have a large dataset and you want to move variables to different locations in the dataset. In SPSS, you can do this by dragging and dropping the variables. However, in a very large dataset, that can take a long time. A much easier approach is to use syntax. Syntax allows you to move a variable to a specific location in the dataset relatively quickly. Below are some examples of the syntax you would use to move variables to various locations.

Moving a Variable from the Bottom (or End) of a Dataset to the Top (or Beginning)

edit

When you create new variables through recoding or by computing a variable, the variable is always created at the bottom or end of the dataset. To move a variable from the bottom of the dataset to the top, you can use the following syntax:

MATCH FILES FILE=*
  /KEEP=bottomvariable, topvariable TO secondtobottomvariable
  ALL.

Where "bottomvariable" is the very last variable in your dataset, the "topvariable" is the very first variable in your dataset, and "secondtobottomvariable" is the variable just above the last variable. This syntax will move the "bottomvariable" variable to the very top of the dataset.

Moving a Variable from a Specific Position to the Bottom (or End) of a Dataset

edit

If you wanted to move a variable that is in the middle of the dataset to the bottom, you could use this syntax:

MATCH FILES FILE=* 
    /KEEP=variable01 TO variable14, 
          variable16 TO variable36, 
          variable15 
          ALL. 

Where "variable15" is the variable you want to use and it is the 15th variable in the dataset. The syntax tells SPSS to keep variables 1 through 14 where they are, as well as variables 16 through 36. However, it tells SPSS to move variable 15 to the end of the dataset.