RENAME Subcommand (GET command)

RENAME changes the names of variables as they are copied into the active dataset.

  • The specification on RENAME is a list of old variable names followed by an equals sign and a list of new variable names. The same number of variables must be specified on both lists. The keyword TO can be used on the first list to refer to consecutive variables in the data file and on the second list to generate new variable names. The entire specification must be enclosed in parentheses.
  • Alternatively, you can specify each old variable name individually, followed by an equals sign and the new variable name. Multiple sets of variable specifications are allowed. The parentheses around each set of specifications are optional.
  • Old variable names do not need to be specified according to their order in the data file.
  • Name changes take place in one operation. Therefore, variable names can be exchanged between two variables.
  • Variables cannot be renamed to scratch variables.
  • Multiple RENAME subcommands are allowed.
  • On a subsequent DROP or KEEP subcommand, variables are referred to by their new names.

Example

GET FILE='/data/empl88.sav' 
  /RENAME  AGE=AGE88 JOBCAT=JOBCAT88.
  • RENAME specifies two name changes for the active dataset. AGE is renamed to AGE88 and JOBCAT is renamed to JOBCAT88.

Example

GET FILE='/data/empl88.sav' 
  /RENAME (AGE JOBCAT=AGE88 JOBCAT88).
  • The name changes are identical to those in the previous example. AGE is renamed to AGE88 and JOBCAT is renamed to JOBCAT88. The parentheses are required with this method.