Adding User-Written Code to the Precode and Postcode Tab

Problem

You want to set a SAS option, assign a libref, or perform some other action immediately before or after a job or transformation is executed.

Solution

You can add the user-written code on the Precode and Postcode tab in the properties window for a job or transformation. For example, you can add a libref to an existing job that enables you to use a table from an unregistered library, as in the following sample job.

Tasks

Add the User-Written Code to the Precode or Postcode Field

Perform the following steps to insert the user-written code:
  1. Create a job, or open an existing job. The sample job, which is named Extract Job, is shown in the following display.
    Sample Process Flow
    Sample Process Flow
  2. Open the Precode and Postcode tab in the properties window for the transformation or job that you need to change. In the sample job, the code is added to the job itself in order to provide access to the target table, ALL_FEMALE_EMP.
  3. Select the appropriate Precode or Postcode check box. The check box that you select depends on whether the user-written code that you add runs before or after the source code for the job or transformation. The sample job requires precode.
  4. Enter the user-written code in the field that is associated with the selected check box. The code shown in the following display is entered into the sample job.
    Sample User-Written Precode
    Sample User-Written Precode

Save the User-Written Code to a File

This is an optional task. Perform the following steps to save the user-written code to a file that you can reuse:
  1. Click the Save As button to access the Save As window.
  2. Select the File check box. Then, enter a server, name, and location for the file in the appropriate fields. The settings for the sample job are shown in the following display.
    Sample Save As Window
    Sample Save As Window
    Note: You can also select the Metadata check box and save the user-written code to the metadata server. In any case, the Save As window applies your changes to the current session. To make your changes persist after the current session, you must save the entire job. To save the entire job, select Filethen selectSave from the menu bar on the desktop.
  3. Click OK to save the file and return to the properties window. Later, you can reuse the code in the file. Simply click the appropriate Open button on the Precode and Postcode tab.
  4. Open the Code tab to verify that the user-written code is added to the job. The following display shows a portion of the Code tab for the sample job.
    Sample Code Tab Content
    Sample Code Tab Content
  5. Click OK to save the changes to the job or transformation and close the properties window.