Selecting Variables
Previous Topic  Next Topic 

Variables to be transferred can be selected when you are using the COPY command from the Stat/Transfer command processor or when you are using a command file.


When you are using a command file at the operating system command line, you can enter operators for variable selection.  However, transfers that are typed in at the  operating system command line will transfer all of the input variables.


Variables can be selected with one of the commands KEEP, DROP, or TYPES.  Only one of these commands can be given and it must be given prior to the COPY command.


KEEP and DROP Commands

The commands KEEP or DROP are used when you wish to select variables but do not wish to change the output variable types assigned by Stat/Transfer.


You can use the SET command DROP-KEEP to reuse the same variable list for more than one transfer.


You can give the variables that you wish to transfer or to omit either as a list or in a file.


Specifying a List of Variables

KEEP or DROP can be followed by a list of variables to be used or omitted, respectively.  The variables should be separated by spaces or commas.


      KEEP|DROP variablelist


Ranges can be given and wildcards are allowed.  For example:


      drop age,sat1-sat10,inc*


will drop the variables 'age', 'sat1' through 'sat10' and all fields beginning with 'inc'.


Using a File to Specify Variables with KEEP or DROP

If you have a file containing a list of variables to be kept or dropped, then instead of a variable list after the KEEP or DROP commands, you can specify the name of the file, preceded with an @ symbol.  For example:


       keep @varkeep.lst


will read the file varkeep.lst for a list of variables to be kept.  These can be delimited with spaces or new lines.  The VARS command, discussed below, can be used to create the file.


Note that files used with KEEP or DROP cannot contain the target output types for input variables.  Such files must be read with the TYPES command.


The VARS Command

To facilitate the creation of a file containing selected input variables, a command is available that will write a list of variables to a file:


        VARS filename variablelist [-oc]


where filename is the name (with a standard extension) of the input file containing the variables to be transferred and variablelist is the name of the file that is to contain the data list.  All of the input variables will be written, one per line, unless the parameter '-oc' has been given  If variable labels are available, these will also be written as comments in the file.


The parameter '-oc', the drop-constants option, is used if you wish to drop constant or missing variables from the variable list you are creating.


Once the file has been created, you can use your favorite editor to delete the variables that are not to be used with the DROP or KEEP command.


Writing to the Screen

If, for some reason, you wish to have the input variables listed on the screen, use the VARS command without specifying an output file


    VARS filename


See also: Changing Output Variable Types