SAS Example - How to write to an output dataset on the mainframe.

Community Help: SAS - Code example writing output file on mainframe

Share your own experience     View front page

The following shows a SAS coding example writing data to a mainframe output file.

First off, in your JCL setup your output file to write to, we'll call it OUTEXAM and just use LRECL 45 bytes, you can use whatever you want.

//OUTEXAM  DD UNIT=CSDTSO,SPACE=(CYL, (100,10),RLSE),
//         DISP= (NEW,CATLG,DELETE),
//         DCB= (LRECL=45,BLKSIZE=0,RECFM=FB),
//          DSN=TEST.FILE.DATAOUT


Now, assuming you used SAS to merge or format your data, you now write it to OUTEXAM as shown. I'm assuming your SAS merged file was named FILEXAM DATA_NULL_;
  SET FILEXAM;
  FILE OUTEXAM NOPRINT;
  PUT @1 'TEST DATA'
      @27 DOLLARNUM
      @35 DATEOUTP;
RUN;

This above will take your SAS data named FILEXAM, and write it to your JCL output file called TEST.FILE.DATAOUT. The 3 fields written will be written at byte position 1, byte position 27, and byte position 35.