Mar 23, 2010

Running SAS on Mainframe in Batch Mode with JCL

How to Run SAS on the OS/390 Mainframe


There are two ways to execute a SAS program on the OS/390 mainframe:
Batch
This is used for large jobs, jobs requiring the use of tape datasets, or jobs where you need paper output.
Interactive
This is used for any of the interactive SAS systems (ASSIST, CALC, etc.), for SAS/GRAPH when the graphics output is to be displayed on the screen of a graphics terminal, or when wanting to see the results of a relatively small SAS program without the need for printed output.

Batch Processing

Use ISPF to input your SAS program along with the appropriate Job Control Language (JCL) (called a SAS job), use the SUBMIT command to send the job to the OS/390 mainframe for processing, and use IOF to get your results when the job completes.
To execute a SAS job batch, use the following JCL:
       //  standard job statement
       //  EXEC   SAS
       //G.SYSIN   DD   *
           SAS Program Goes Here
       //
If you need to include any other JCL statements to point to external data files or SAS Data Libraries, these JCL statements should be placed between the EXEC and SYSIN DD statements.

Interactive Processing

Execute the SAS program as you are sitting in front of your terminal, and see the results of each DATA or PROCedure step as it completes. The program could be entered using ISPF before invoking SAS and then included into the interactive session, entered under the Display Manager during the interactive session, or there can be no actual programming required (as when using SAS/ASSIST).
To invoke interactive SAS, from the READY prompt or from the ISPF Primary Options Panel, enter:
       SAS
This will put you into the Display Manager with the PROGRAM EDITOR window at the bottom of the screen and the LOG window at the top of the screen. From here you can enter your SAS program, invoke ASSIST, etc. To end an Interactive SAS session, enter BYE at the COMMAND line.
 
How to convert a SAS data set from the mainframe to SAS for Windows?
Answer:
There are two methods in transferring a SAS file to other platforms: using XPORT engine and PROC CPORT.  This FAQ focuses on the former method, which performs transportation of data file only.  For the second method, which does the SAS catalogs, consult the SAS manual SAS Companion for the MVS Environment. Version 6, Second Edition (pp. 134-7) (SAS/MVS hereafter).
To move SAS data sets from one environment to another, it is necessary to convert the file into a transport file format.  The following introduces a four-step procedure to transfer the file from MVS to local host (PC) via CMS.
1.  Convert the SAS file into a transport file format using the following program:
//IDXXORTZ JOB (IDXX,2,20),'YOURNAME',CLASS=A,PASSWORD=XXXXXX,
// USER=IDXX
/*ROUTE PUNCH UNTVM1.IDXX
/*ROUTE PRINT UNTVM1.IDXX
// EXEC IEFBR14
//TRANS DD DSN=USER.IDXX.TEST.TRANS,UNIT=SYSDA,
//      VOL=SER=ACAD03,DISP=(OLD,DELETE)
// EXEC SAS
//TRANS DD DSN=USER.IDXX.TEST.TRANS,UNIT=SYSDA,
//    VOL=SER=ACAD03,DISP=(NEW,KEEP),
//    SPACE=(CYL,(50,20),RLSE),
//    DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
//DATA1 DD DSN=USER.IDXX.TEST.SAS,UNIT=SYSDA,
//    VOL=SER=ACAD03,DISP=SHR
//SYSIN DD *
LIBNAME TRANS XPORT;
PROC COPY IN=DATA1 OUT=TRANS MEMTYPE=DATA;
run;
This program converts a SAS system file located on MVS system disk (ACAD03) into a transport file on the same disk.  The IEFBR14 procedure cleans up any file previously created in the same name. Note that the boldfaced DCB (Data Control Block) specification, which fixes the LRECL (Logical Record Length) to 80, is the key for the file conversion.   The new transport file MUST BE a sequential file in 80 columns.
2. To download this file to CMS, use the following IEBGENER program:
//IDXXORTZ JOB (IDXX,12,999),'YOURNAME',
//        CLASS=N,PASSWORD=XXXXXX,USER=IDXX
/*JOBPARM CARDS=9999999
/*ROUTE PRINT UNTVM1.IDXX
/*ROUTE PUNCH UNTVM1.IDXX
//STEP1  EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=A
//SYSIN DD DUMMY
//SYSUT1 DD DSN=USER.IDXX.TEST.TRANS,DISP=(OLD,KEEP),UNIT=SYSDA,
//          VOL=SER=ACAD03
//SYSUT2 DD SYSOUT=B
 

This program downloads the transport file from the MVS system disk ACAD03 to the CMS environment and the PUNCH output (the SAS transport file) will be routed to the user's READER LIST.  Preparing for large data set, this program specifies CLASS=N and a large number for the JOBPARM parameter.  It is recommended to create a temporary disk before receiving the file to CMS.  To create a temporary disk in CMS, type:
tempdisk
at the Ready mode.  Specify the number of cylinders for temporary storage.  By default, the temporary 193 disk will be created as the E disk.  Copy the file from the READERLIST to E disk by receiving the transport file into TEST TRANSPRT E1.  At the command column, type:
RECEIVE / TEST TRANSPRT E1
3.  Use FTP to download the transport file to any local host (UNIX or PC).  For detailed instructions, consult the RSS document Transferring Files to and From CMS (http://www.unt.edu/rss/docs/cmsftp.htm). Specify the binary mode for file transferral.
4.  Import the SAS transport file into SAS for Windows (v 6.12) using the following program:
libname trans xport 'c:\temp\test.tra';  /* transport file */
libname new 'c:\temp'; /* output library */
proc copy in=trans out=new;
run;
Note that the first libname statement points to the transport FILE instead of a directory.  The file name of the original transport file has been truncated to test.tra.  The XPORT keyword specifies the engine type of the library.  The new SAS system file (v 612 for Windows) will be created under the directory ‘c:\temp' with the file name test.sd2.