Variable Transformations

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 (Figure 32.21).

ugtransformcustom1.png (8390 bytes)

Figure 32.21: Selecting a Custom Transformation

The second page of the wizard provides a window for you to enter DATA step code. The wizard displays the page shown in Figure 32.22.

ugtransformcustom2.png (7851 bytes)

Figure 32.22: A Window for Entering DATA Step Code


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

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.

Note that the dialog box shown in Figure 32.22 contains a DATA step template satisfying the first three conditions in the previous list. It is up to you to satisfy the last condition by inserting code 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 code, you can again select Analysis \blacktriangleright\,Variable Transformation from the main menu and attempt to correct your error. Custom transformations are not remembered between SAS/IML Studio sessions.


Example

Previous Page | Next Page | Top of Page