Changing Output Variable Types
Previous Topic  Next Topic 

The TYPES Command

If you wish to change the output variable target type manually, then instead of using a KEEP or DROP command, you use the TYPES command and a file, vartypelist, containing the selected input variables and their target output types.

      TYPES  vartypelist

Note that a @ symbol does not precede the file name.

For example,

      types type.lst

will read the file type.lst for a list of variables to be used, along with the target output type chosen.  Each variable along with the target output type must be on a separate line.

When you use the TYPES command, you should not give any of the optimization parameters '-o'. '-of ', '-oc', or '-ofc' with the COPY command.

The VARS command, which is used to create the file, vartypelist, is discussed below.


When a TYPES command has been given it will be used with all succeeding COPY commands, until a new TYPES command has been given or until the following command is given.


The VARS Command

The VARS command, given at the Stat/Transfer prompt with appropriate options, can be used to write a file giving the output variable types assigned by Stat/Transfer, as well as variable names and labels:

    VARS filename vartypelist [-t] [-o[f][c]]

where filename is the name of the input file and vartypelist is the name of the file that is to contain the variable list with variable types.  All of the input variables will be written, unless the parameter '-oc' has been given.  They will be written one per line, and if variable labels are available, these will also be written as comments in the file.

The parameters '-t' and '-o' must be given. The parameter '-t' will write out the target output type for each input variable, while the parameter '-o' optimizes the output variable types.  The '-of', '-oc', and '-ofc' parameters will select optimized types with the float and drop-constants options before writing the variable list.

Once the file has been created, you can use any editor to delete the variables that are not to be transferred and to change any output types you wish. The resulting file should still have one line for each variable that you wish to transfer.

Note that the only checking that is done at the time the TYPES command is given after a COPY command is for the existence of the file, so that editing needs to be done with care.

Changing Target Output Types

Valid types are string, byte, int, long, float, double, date, time, and date/time (see Target Output Variable Types).  You should be careful not to choose a smaller type than that chosen by Stat/Transfer unless you are sure you know more about your data than Stat/Transfer does.

Output variable types can be changed freely for ASCII files and worksheet files.  For all other file formats, you can change freely among the numeric types of 'byte', 'integer', 'long', 'float' and 'double' and you can change among the time types.  However, do not make changes such as string to number, or number or string to date.

Remember that you are selecting a "target" type.  If the output data format does not support the specific type you have selected, then Stat/Transfer will use the best match to the type you have selected

You can determine the output variable types supported by a given output file type by consulting the table given in the section describing that file format.

Using Editable Stat/Transfer Schemas

If you want to make numerous changes to your data, consider writing your data to delimited ASCII with a Stat/Transfer schema. This allows you to do many changes, such as changing variable types, renaming and rearranging variables, and so on. 

See also:  Selecting Variables