Batch Processing Using SAS Under Zos
Batch Processing Using SAS Under Zos
®
SAS under z/OS
Course Notes
For Your Information ii
Batch Processing Using SAS® under z/OS Course Notes was developed by Travis Masters and Mark
Jordan. Editing and production support was provided by the Curriculum Development and Support
Department.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of
SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product
names are trademarks of their respective companies.
Book code E70238, course code MVSB9, prepared date 16Oct06 MVSB9_002
For Your Information iii
Table of Contents
Prerequisites ................................................................................................................................. v
Chapter 1 Getting Started with SAS Software under z/OS ................................. 1-1
Course Description
Batch Processing Using SAS® under z/OS Course Notes teaches you how to use ISPF under z/OS to
create and submit SAS programs in batch mode and to view resulting output. You also learn basic Job
Control Language (JCL) related to batch processing. This course is designed to be taught in
approximately one hour. It is not offered publicly; it is available for on-site presentation only.
To learn more…
For a list of other SAS books that relate to the topics covered in this
Course Notes, USA customers can contact our SAS Publishing Department at
1-800-727-3228 or send e-mail to sasbook@sas.com. Customers outside the
USA, please contact your local SAS office.
Also, see the Publications Catalog on the Web at support.sas.com/pubs for a
complete list of books and a convenient order form.
For Your Information v
Prerequisites
Prior experience with the Interactive System Production Facility (ISPF)/Program Development Facility
(PDF) under z/OS is recommended. Some experience with SAS software will enhance your
understanding of the ‘‘Common Programming Errors’’ section of the course.
vi For Your Information
General Conventions
This section explains the various conventions that may be used in presenting text, SAS language syntax,
and examples in this book.
Typographical Conventions
You will see several type styles in this book. This list explains the meaning of each style:
UPPERCASE ROMAN is used for SAS statements and other SAS language elements when they
appear in the text.
italic identifies terms or concepts that are defined in text. Italic is also used for
book titles when they are referenced in text, as well as for various syntax
and mathematical elements.
bold is used for emphasis within text.
monospace is used for examples of SAS programming statements and for SAS character
strings. Monospace is also used to refer to variable and data set names, field
names in windows, information in fields, and user-supplied information.
select indicates selectable items in windows and menus. This book also uses icons
to represent selectable items.
Syntax Conventions
The general forms of SAS statements and commands shown in this book include only that part of the
syntax actually taught in the course. For complete syntax, see the appropriate SAS reference guide.
Objectives
After completing this section you will know how to do the
following:
Enter and submit SAS programs in the Interactive
System Production Facility (ISPF)/Program
Development Facility (PDF).
Save SAS programs.
continued...
Objectives
Use the Spooled Data Set Facility (SDSF) or
Interactive Output Facility (IOF) to view your SAS log
and SAS output.
Purge (release) held output files.
4
1-4 Chapter 1 Getting Started with SAS Software under z/OS
Even if you use ISPF, the commands issued to submit batch jobs can differ from the commands in this
course. Record your location-specific information in the spaces provided throughout the course notes.
05_READY_Prompt.gif
06_ISPF_Main_Menu.gif
7
1-6 Chapter 1 Getting Started with SAS Software under z/OS
Function Keys
Type KEYS on the Option line and press ENTER to see
function key definitions in an editable panel. Return to the
ISPF Primary Option Menu by issuing the END command.
07_Keylist.gif
08_Selecting_EDIT.gif
_________________________________________________________________
1.1 Fundamental Concepts 1-7
10_Batch1_Code.gif
11
________________________________________________________________
EXEC
SYSIN
12
1-8 Chapter 1 Getting Started with SAS Software under z/OS
13
14
1.1 Fundamental Concepts 1-9
//SYSIN DD DSN=
or
//SYSIN DD *
15
For more complete JOB, DD, and EXEC statement syntax, see the optional Advanced JCL
section.
16_Edit_JCL.gif
16
1-10 Chapter 1 Getting Started with SAS Software under z/OS
17_Basic_JCL.gif
17
This file will serve as your JCL template. Copy it into your SAS program so that the SAS statements
come after the SYSIN DD* statement prior to submitting your code in batch.
SYSIN Statement
There are three ways to use the SYSIN statement to
identify the SAS program to process:
1. Use DSN= to point to the file that contains your
program.
18_JCL_with_DSN.gif
continued...
18
1.1 Fundamental Concepts 1-11
SYSIN Statement
2. Use the SAS mMacro statement %INCLUDE to bring
SAS code into the SAS session from a file or PDS
member.
19_JCL_with_INCLUDE.gif
continued...
19
If your stored program contains JCL (or if you do not know whether the program contains JCL), use the
JCLEXCL option in the %INCLUDE statement. For example:
SYSIN Statement
3. Use DD * to indicate that SAS code follows the JCL
statements in the same file.
20_JCL_with_INLINE_CODE.gif
20
1-12 Chapter 1 Getting Started with SAS Software under z/OS
Copying JCL
If your basic JCL file uses //SYSIN DD * and is stored in
the same partitioned data set (PDS) as your SAS
programs, you can easily copy the JCL into SAS
programs for batch submission.
21
1.1 Fundamental Concepts 1-13
Copying JCL
Access the SAS program.
Place the line command B (Before) on the line number of
program line 000001.
Type COPY on the command line with the member name
where the JCL is saved and press ENTER.
22_Copy_in_JCL.gif
22
_________________________________________________________________
At my location, to copy one file to another, I
_________________________________________________________________
1-14 Chapter 1 Getting Started with SAS Software under z/OS
23_Submit_from_Editor.gif
23
1.1 Fundamental Concepts 1-15
24
_________________________________________________________________
After submitting the program, to return to the main ISPF menu, I
_________________________________________________________________
1-16 Chapter 1 Getting Started with SAS Software under z/OS
25_Selecting_SDSF.gif
25
_________________________________________________________________
To access that output facility, I
_________________________________________________________________
1.1 Fundamental Concepts 1-17
26_SDSF_QUEUE.gif
26
_________________________________________________________________
27_SDSF_Select_Job.gif
27
1-18 Chapter 1 Getting Started with SAS Software under z/OS
28_SDSF_Select_SASLOG.gif
28
_________________________________________________________________
At my location, the SAS output is named
_________________________________________________________________
At my location, to view the log and output, I
_________________________________________________________________
1.1 Fundamental Concepts 1-19
29_SDSF_Viewing_SASLOG.gif
29
30_SDSF_Select_OUTPUT.gif
continued...
30
1-20 Chapter 1 Getting Started with SAS Software under z/OS
31_SDSF_View_OUTPUT.gif
31
Continue to issue the END command to return to the ISPF Primary Option Menu.
32_Edit_Panel.gif
continued...
32
1.1 Fundamental Concepts 1-21
33_BATCH2_SASCODE.gif
continued...
33
34_BATCH2_Copy_JCL.gif
continued...
34
1-22 Chapter 1 Getting Started with SAS Software under z/OS
35_BATCH2_Submit.gif
35
36_IOF_Selecting_Job.gif
36
1.1 Fundamental Concepts 1-23
37_IOF_Selecting_SASLOG.gif
37
38_IOF_View_SASLOG.gif
38
1-24 Chapter 1 Getting Started with SAS Software under z/OS
39_IOF_View_SASLIST.gif
41
18_JCL_with_DSN.gif
42
1-26 Chapter 1 Getting Started with SAS Software under z/OS
43_Multiple_DSNs.gif
43
19_JCL_with_INCLUDE.gif
44
1.2 Combining and Editing SAS Programs 1-27
45_Multiple_INCLUDES.gif
45
Copying Steps
Access the Edit Entry Panel for your new program.
Copy in the first step using the COPY command.
46_Copy_Multiple_Programs.gif
continued...
46
1-28 Chapter 1 Getting Started with SAS Software under z/OS
Copying Steps
Repeat for the second program. Use the A line command
to specify where the new text should start.
47_Copy_Multiple_Programs.gif
47
In Insert n lines
Dn Delete n lines
Cn Copy n lines
Mn Move n lines
Rn Repeat n lines
48
1.2 Combining and Editing SAS Programs 1-29
49
Copying Steps
Delete any duplicate steps and the duplicate JCL. (Use a
block delete (DD) command.)
50_Copy_Multiple_Programs2.gif
50
1-30 Chapter 1 Getting Started with SAS Software under z/OS
51_Modify_Program_2.gif
51
52_Modify_Program_3.gif
52
1.2 Combining and Editing SAS Programs 1-31
53_Modify_Program_4.gif
...
53
54_Modify_Program_5.gif
54
1-32 Chapter 1 Getting Started with SAS Software under z/OS
55_Submit_Copied_Programs.gif
55
56_View_Log.gif
56
1.2 Combining and Editing SAS Programs 1-33
57_View_Output.gif
57
58_Purge_SDSF_Queue.gif
58_Purge_IOF_Queue.gif
58
________________________________________________________________
1-34 Chapter 1 Getting Started with SAS Software under z/OS
Exercises
The files containing the programs are stored as members of a partitioned data set (PDS) named
userid.PROG1.SASCODE. In the partitioned data set are several SAS programs and a member called
JCL, which contains basic JCL statements.
1. Submitting Your First Program
a. Access the JCL. Supply your name and user ID. Return to the main menu.
b. Access the program named C02EX1. The program contains a DATA step that creates a SAS data
set named AIRPORTS and a PRINT procedure step that prints the data set.
c. Place an asterisk before the INFILE statement on line 2
d. Delete the asterisk before the INFILE statement on line 3
e. Copy the JCL before the SAS program.
f. Submit the program.
g. Save your changes and return to the main menu.
h. Using IOF, SDSF, or your output facility, view the SAS log and SAS output.
2. Submitting a Second Program
a. Access the file named C02EX2. The file contains a PROC CHART step that produces a vertical
bar chart of flight departure delays.
b. Copy the JCL before the SAS program and submit it.
c. Save your changes and return to the main menu.
d. Using IOF, SDSF, or your output facility, view the SAS log and SAS output.
1.2 Combining and Editing SAS Programs 1-35
Don’t forget to save! You will use this program in a future exercise.
g. Using IOF, SDSF, or your output facility, view the SAS log and SAS output.
h. Release all held files.
4. Editing an Existing Program
The program C02EX4 contains a DATA step and both PRINT and MEANS procedure steps. The
DATA step creates a SAS data set named DFWLAX. The PROC MEANS step produces a report with
minimum, average, and maximum number of First Class and Economy passengers on the flights. The
PROC PRINT step produces a listing report of the DFWLAX data set.
Make the following modifications:
a. Add this TITLE statement to the PROC MEANS step after the VAR statement. Be sure to enter
both quotation marks.
title 'Average, Minimum, & Maximum Passenger Loads';
b. Move the PROC MEANS step after the PROC PRINT step.
c. Add the following TITLE statement to the PROC PRINT step. Be sure to enter both quotation
marks.
title 'Passenger Data for DFW/LAX Flights';
d. Submit the program and view the SAS log and SAS output. The program should first produce the
listing report, which contains all variables and all observations in the DFWLAX data set, and
second the basic statistical report, which shows the average, minimum, and maximum number of
passengers in First Class and Economy. Each report should have a different, appropriate title.
1-36 Chapter 1 Getting Started with SAS Software under z/OS
Objectives
After completing this section, you will be able to
recognize SAS error and warning messages
identify
– missing semicolons
– unbalanced quotation marks
use the ISPF text editor to correct errors.
61
Syntax Errors
When you make errors such as misspelling SAS
keywords, forgetting semicolons, or specifying invalid
options, the SAS System prints the following in the SAS
log:
the word ERROR or WARNING
62
1.3 Common Programming Errors 1-37
Syntax Errors
Example:
Submit the BATERROR program, read the messages in
the SAS log, and correct any errors.
63_Batch_Error.gif
63
Interpreting Messages
View the SAS log.
64_Batch_Error1.gif
64
Interpreting Messages
Scroll forward to view the entire SAS log.
65_Batch_Error2.gif
65
________________________________________________________________
Interpreting Messages
Analysis of the log indicates:
The data set IA.FLIGHT114 was sorted successfully
into the output data set WORK.FLIGHT.
the TABULATE procedure failed:
“Error 73-322 – Expecting an =.”
– SAS expected to find ‘=‘ after the DATA key word
in the PROC TABULATE statement.
– The statement must be corrected and the job re-
submitted.
66
1.3 Common Programming Errors 1-39
67
Omitting a Semicolon
Another very common programming error is omitting a
semicolon at the end of a statement.
Example: In the BATSEMI program, Line 6 does not end
with a semicolon.
68_Missing_Semicolon.gif
68
1-40 Chapter 1 Getting Started with SAS Software under z/OS
Omitting a Semicolon
The error messages in the SAS log may not appear
germane to the actual programming error.
69_Missing_Semicolon_Log.gif
70_Unbalanced_Quotes.gif
70
1.3 Common Programming Errors 1-41
71_Unbalanced_Quotes_Log.gif
71
72_Unbalanced_Quotes_Output.gif
72
To resolve the problem in batch mode, find the missing quotation mark and insert one in the
proper location in your code, then resubmit the program.
1-42 Chapter 1 Getting Started with SAS Software under z/OS
Exercises
The files containing the programs are stored as members of a PDS named userid.PROG1.SASCODE.
5. Correcting Errors
a. Submit the file named C02EX5. The file contains a DATA step, a PRINT procedure step, and a
MEANS procedure step. The DATA step creates a SAS data set named DFW, the PROC PRINT
step prints the data set, and the PROC MEANS step requests the average, minimum, and
maximum pounds of mail on these flights.
b. View the SAS log and determine the error(s).
c. Correct the errors in the program and submit the corrected version.
d. View the SAS log and SAS output.
1.4 SAS Windowing Environment (Optional) 1-43
Objectives
After completing this section, you should be able to
use the SAS Windowing Environment to write,
edit, and submit programs
view your output in the SAS Windowing Environment
75
1-44 Chapter 1 Getting Started with SAS Software under z/OS
75_Starting_Interactive_SAS.gif
76
___________________________________________________________
77
1.4 SAS Windowing Environment (Optional) 1-45
edit programs
submit programs.
78
79
1-46 Chapter 1 Getting Started with SAS Software under z/OS
78_Include_a_Program.gif
80
79_Delete_JCL.gif
81
All of the text editor line commands that you learned for batch mode are available in the Program
Editor window. Just as in ISPF, some commands can be submitted quickly and easily using
function keys. To review and / or modify function key definitions, issue the KEYS command.
1.4 SAS Windowing Environment (Optional) 1-47
80_Submit.gif
82
When developing SAS programs with very large data sets, system options can make the use of the SAS
windowing environment more effective. For example, the OBS=5 system option stops each SAS process
at the fifth observation in the referenced data sets.
Furthermore, if your DATA step works properly, you do not have to resubmit the DATA step to test your
procedures on a temporary data set because the data remains available until the SAS session terminates.
1-48 Chapter 1 Getting Started with SAS Software under z/OS
81_Output.gif
83
82_Get_LOG.gif
84
1.4 SAS Windowing Environment (Optional) 1-49
83_View_LOG.gif
85
84_Recall.gif
86
1-50 Chapter 1 Getting Started with SAS Software under z/OS
85_Save_Program.gif
87
86_endsas.gif
SAS terminates and returns you to the READY prompt.
88
1.4 SAS Windowing Environment (Optional) 1-51
Exercises
The files containing the programs are stored as members of a PDS named userid.PROG1.SASCODE.
6. Using the SAS Windowing Environment.
a. Include the file C02MYEX3.
b. Delete the JCL. Add this statement at the beginning of the program:
OPTIONS OBS=10;
Objectives
After completing this section, you should be able to
write more complex JCL statements
91
JCL Syntax
JCL involves a complex, rigidly applied set of rules.
A subset of the rules includes:
Record length for JCL files must be 80 characters
JCL statements
92
1.5 Additional JCL (Optional) 1-53
JCL Syntax
Continue a JCL statement by ending the first line with
a comma after a complete parameter.
The continuation line must:
– Begin with two slashes in columns 1-2
– The first parameter must begin in column 4-16.
– The line must end on or before column 71.
continued...
93
JCL Syntax
Enclose lists of sub-parameters in parentheses,
separated by commas.
Omit a positional parameter or sub-parameter in a list
by marking its place with a comma. If the last
parameter is omitted, no comma is necessary.
Omit the parentheses when using a single (first
parameter or a keyword) sub-parameter from the list
94
1-54 Chapter 1 Getting Started with SAS Software under z/OS
JOB Statement
General form of the JOB statement:
//jobname JOB (acctg info),'name',CLASS=a,
// NOTIFY=userid,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
continued...
95
JOB Statement
//jobname JOB (acctg info),'name',CLASS=a,
// NOTIFY=userid,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
continued...
96
1.5 Additional JCL (Optional) 1-55
JOB Statement
//jobname JOB (acctg info),'name',CLASS=a,
// NOTIFY=userid,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
JOB Statement
//jobname JOB (acctg info),'name',CLASS=a,
// NOTIFY=userid,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
continued...
98
1-56 Chapter 1 Getting Started with SAS Software under z/OS
JOB Statement
//jobname JOB (acctg info),'name',CLASS=a,
// NOTIFY=userid,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
99
1.5 Additional JCL (Optional) 1-57
100
OUTPUT Statements
OUTPUT statement with selected parameters:
//formname OUTPUT DEST=destid,
// COPIES=x,DEFAULT=yn
continued...
101
1-58 Chapter 1 Getting Started with SAS Software under z/OS
OUTPUT Statements
//formname OUTPUT DEST=destid,
// COPIES=x,DEFAULT=yn
102
1.5 Additional JCL (Optional) 1-59
JOBPARM Statements
General form of the JOBPARM statement to control
output:
/*JOBPARM DEST=dest,NAME='formname',COPIES=x
continued...
103
JOBPARM Statements
Special form of the JOBPARM statement to hold output:
/*JOBPARM FETCH
104
1-60 Chapter 1 Getting Started with SAS Software under z/OS
EXEC Statement
General form of the EXEC statement:
continued...
105
EXEC Statement
//stepname EXEC proc|PGM=prog,
// REGION=k,TIME=s
106
1.5 Additional JCL (Optional) 1-61
DD Statements
General form of the Data Definition (DD) statement for
accessing existing data sets:
// ddname DD DSN=project.group.type,
// DISP=disp
continued...
107
DD Statements
// ddname DD DSN=project.group.type,
// DISP=disp
continued...
108
1-62 Chapter 1 Getting Started with SAS Software under z/OS
DD Statements
General form of the Data Definition (DD) statement for
creating new data sets:
//ddname DD DSN=project.group.type,
// DISP=disp
continued...
109
DD Statements
General form of the Data Definition (DD) statement for
creating new data sets:
// ddname DD DSN=project.group.type,
// DISP=(d,n,a),SPACE=(t,(p,s),r),
// UNIT=u,VOL=SER=v
110
1.5 Additional JCL (Optional) 1-63
DD Statements
// ddname DD DSN=project.group.type,
// DISP=(d,n,a),SPACE=(t,(p,s),r),
// UNIT=u,VOL=SER=v
continued...
111
DD Statements
// ddname DD DSN=project.group.type,
// DISP=(d,n,a),SPACE=(t,(p,s),r),
// UNIT=u,VOL=SER=v
SYSDA (group)
v: Volume to which the data set is written. If not
specified, the system chooses a volume with space
available.
112
1-64 Chapter 1 Getting Started with SAS Software under z/OS
continued...
113
In addition:
The file allocates five cylinders initially, and two
cylinders for each subsequent extent.
Unused space is released at the end of the job.
114
1.5 Additional JCL (Optional) 1-65
115
//SASLOG DD DSN=USERID.FILE.LOG,DISP=OLD
//SASLIST DD DSN=USERID.FILE.LIST,DISP=OLD
116
1-66 Chapter 1 Getting Started with SAS Software under z/OS
DD Example: SYSIN
When used with the special label SYSIN, a DD statement
indicates which file(s) contains SAS code to be executed.
//SYSIN DD DSN=EDU000.PROG1.SASCODE(C02S2D1),
// DISP=SHR
// DD DSN=EDU000.PROG1.SASCODE(C02S2D2),
// DISP=SHR
117
118
1.5 Additional JCL (Optional) 1-67
119
1-68 Chapter 1 Getting Started with SAS Software under z/OS
1.6 Chapter Summary 1-69
IOF
SDSF
// SYSIN DD DSN=
or
// SYSIN DD *
General form of the DD, or Data Definition, statement for using existing files:
// ddname DD DSN=userid.data.set,DISP=disp
/* JOBPARM FETCH
121
1-72 Chapter 1 Getting Started with SAS Software under z/OS