Converting a SAS Code File to a Job

Problem

You want to convert a SAS program file to a SAS Data Integration Studio job.

Solution

You can use the Import SAS Code wizard in SAS Data Integration Studio to convert a SAS program file and import it into SAS Data Integration Studio. The sources, targets, and procedures in the program file are rendered as metadata objects in a job.
The Import SAS Code wizard enables you to analyze your code and to automatically create SAS Data Integration Studio jobs. Behind the scenes, it calls the SCA (SAS Code Analyzer) procedure to analyze your SAS program. The SAS Code Analyzer captures information about input, output, and the use of macro symbols from a SAS job while it is running. The output generated is a file with your SAS program and any additional comments.
Note: The Import SAS Code wizard cannot parse all possible LIBNAME options for DBMS engines. If you import SAS code that includes LIBNAME options for DBMS engines, verify that the imported LIBNAME statement is correct, and that you can access the appropriate library. If some LIBNAME options are missing, configure them manually.
Two additional options are available as check boxes. You can select the Expand macros check box. This option creates a node for each step inside of your macros and provides additional detail about your job and how it works, including performance information about slow running steps, which steps use more memory or I/O, and CPU performance. You can also select the Register work tables as physical tables check box. This option registers all work tables as physical tables in a WORK library so that your imported SAS code uses temporary tables that are both the source and target of a step. You can also analyze your job to determine the type and number of steps in your job. This information is provided in a report that you can review prior to importing the job.

Tasks

Review the SAS Program File

Review the SAS program file that you want to import, such as the following sample file:
libname ditest 'c:\\DISdata';

data temp.burgers;
 input where $ 1-18 food $ 19-34 calories fat $ sodium $ id $;
     cards;
 Burger King       cheeseburger    380  19g 780mg 1
 Hardees           cheeseburger    390  20g 990mg 10
 Jack In The Box   cheeseburger    320  15g 670mg 0
 McDonalds         cheeseburger    320  14g 750mg 35
 Wendys            cheeseburger    320  13g 770mg 20
 ;
run;

data temp.lesscalories;
   set temp.burgers;
   where calories < 390;
run;
Note: You can use comment tags to embed comments into the converted job, as follows:
  • ALTERNATE_NODE_NAME: the node name
  • ALTERNATE_NODE_DESCRIPTION: the node description
  • COMMENT: tags that are grouped together into a private note attached to the node
These tags should be placed after the code block for which they are intended.

Import the SAS Program File

Perform the following steps to import the program file:
  1. Right-click the destination folder in SAS Data Integration Studio for the imported program file. Then, click Import SAS Code in the pop-up menu to access the Import SAS Code window. The following display shows the window for a sample program file.
    Import SAS Code Window
    Import SAS Code Window
  2. Click Add and select the SAS program file that contains the code that you need.
  3. Click OK to run the wizard.
    Note: You can view the log file for the run. This log file is created whenever any action is taken. The log file will have a name that equals the program name.log. Therefore, the log in this example is named TestDataset.log.

Open and Run the Job

Perform the following steps to open and run the job:
  1. Open the job that you imported and converted. The job will have the same name as the program file, with (Generated) appended. For example, the SAS program TestDataset.sas becomes the job that is identified as TestDataset (Generated).
  2. Run the job. The following display shows a successfully completed sample job.
    Sample Imported Job
    Sample Imported Job

Review the Output

If the job completes without error, right-click the target table and click Open. The View Data window appears, as shown in the following example.
Sample Target Table Output
Sample Target Table Output