Importing SAS Code

Problem

You want to use the SAS code in a program file in 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 SCAPROC (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.

Tasks

Review the SAS Program File

Review the SAS program file that you want to import, such as the following sample file:
LIBNAME srclib1 BASE "\\d18368\sources\sas1_src";

data srclib1.fishdata1;
   infile datalines missover;
   input Location & $10. Date date7.
         Length1 Weight1 Length2 Weight2 Length3 Weight3
         Length4 Weight4;
   format date date7.;
   datalines;
Cole Pond   2JUN08 31 .25 32 .3  32 .25 33 .3
Cole Pond   3JUL08 33 .32 34 .41 37 .48 32 .28
Cole Pond   4AUG08 29 .23 30 .25 34 .47 32 .3
Eagle Lake  2JUN08 32 .35 32 .25 33 .30
Eagle Lake  3JUL08 30 .20 36 .45
Eagle Lake  4AUG08 33 .30 33 .28 34 .42
;
run;

proc print data=srclib1.fishdata1;
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. Select Convert and import files in the Import options group box.
    Note: This job uses the Convert and import files option to run both the conversion and import processes. You can also select Convert files only to convert the files without importing them. Finally, you can select Import already converted files to import previously converted files.
  4. 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 fish.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 fish.sas becomes the job that is identified as fish (Generated).
  2. Run the job. The following display shows a successfully completed sample job.
    Sample Imported Job
    Sample Imported Job

Review the Output

Perform the following steps to review the output of the job:
  1. 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
  2. Click the Output tab. The following display shows output from a sample job.
    Sample Output Tab
    Sample Output Tab