Custom Transformations

While SAS/IML Studio provides many standard transformations, the most powerful feature of the Variable Transformation Wizard is that you can use the SAS DATA step to create new variables defined by arbitrarily complex formulas. You can define custom transformations after selecting Custom from the Family list in the Variable Transformation Wizard. (See Figure 32.21.)

Figure 32.21: Selecting a Custom Transformation


The second page of the wizard provides a window where you can enter DATA step statements. The wizard displays the page shown in Figure 32.22.

Figure 32.22: A Window Where You Can Enter DATA Step Statements


You can enter any valid DATA step statements into this window, with the following conditions:

  • The statements must begin with a DATA statement.

  • The statements must include a SET statement.

  • The statements must end with a RUN statement.

  • The statements must create an output data set that contains the same number of observations as the data table (or the same number as are included in analyses).

The data set specified in the SET statement is called the input data set. The data set specified in the DATA statement is called the output data set.

The DATA step template shown in Figure 32.22 satisfies the first three conditions in the previous list. It is up to you to satisfy the last condition by inserting statements before the RUN statement.

The name of the output data set defaults to _VarTransform; the name of the input data set is automatically generated based on the name of your data table. You can accept these default data set names, or you can enter different names.

When you click Finish, the following steps occur:

  1. SAS/IML Studio scans the text in the window. If the names of any variables in the current data table are found in the text, then these variables are written to the input data set on the SAS server.

  2. The DATA step is executed on the server. This creates the output data set.

  3. The variables in the output data set are compared with the variables in the input data set.

    1. Any variables in the output data set that are not in the input data set are copied from the server and added to the current data table.

    2. Any variables common to the input and output data sets are compared. If the DATA step changed any values, the new values are copied to the current data table.

  4. The input and output data sets are deleted from the server.

Each workspace remembers the last custom transformation you entered. If there is an error in your DATA step statements, you can again select MenuitemAnalysis →Variable Transformation from the main menu and attempt to correct your error. Custom transformations are not remembered between SAS/IML Studio sessions.