Batch Processing Using SAS under z/OS

Batch Processing Using
®
SAS under z/OS
Transcript
Batch Processing Using SAS® under z/OS Transcript was developed by Michelle Buchecker. Additional
contributions were made by Brian Gayle, Mark Jordan, Travis Masters, Kent Reeve, and Jim Simon.
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.
Batch Processing Using SAS® under z/OS Transcript
Copyright © 2009 SAS Institute Inc. Cary, NC, USA. All rights reserved. Printed in the United States of
America. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written
permission of the publisher, SAS Institute Inc.
Book code E1554, course code RLSPBATC, prepared date 24Nov2009.
RLSPBATC_001
ISBN 978-1-60764-234-3
For Your Information
Table of Contents
Lecture Description ..................................................................................................................... iv Prerequisites ................................................................................................................................. v Accessibility Tips ......................................................................................................................... v Batch Processing Using SAS® under z/OS ................................................................... 1 1.
Fundamental Concepts ........................................................................................................ 5 2.
Combining and Editing SAS Programs ............................................................................ 39 3.
Additional JCL .................................................................................................................. 59 iii
iv
For Your Information
Lecture Description
This lecture teaches you the basics of how to submit SAS jobs in batch using JCL under the z/OS
operating system.
To learn more…
For information on other courses in the curriculum, contact the SAS Education
Division at 1-800-333-7660, or send e-mail to [email protected]. You can also
find this information on the Web at support.sas.com/training/ as well as in the
Training Course Catalog.
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 [email protected]. 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.
H
H
For Your Information
v
Prerequisites
Before listening to this lecture, you should be able to
• write DATA and PROC steps
• understand error messages in the SAS log and debug your program.
Accessibility Tips
If you are using a screen reader, such as Freedom Scientific’s JAWS, you may want to configure your
punctuation settings so that characters used in code samples (comma, ampersand, semicolon, percent) are
announced. Typically, the screen reader default for the character & is to read “and.” For clarity in code
samples, you may want to configure your screen reader to read & as “ampersand.” In addition, depending
on your verbosity options, the character & might be omitted. The same is true for some commas before a
code variable. To confirm code lines, you may choose to read some lines character by character. When
testing this scenario with Adobe Acrobat Reader 9.1 and JAWS 10, ampersands before SAS macro names
were announced only when in character-reading mode.
vi
For Your Information
Batch Processing Using SAS® under
z/OS
1. Fundamental Concepts ..................................................................................................... 5 2. Combining and Editing SAS Programs ......................................................................... 39 3. Additional JCL ................................................................................................................. 59 2
Batch Processing Using SAS® under z/OS
1. Fundamental Concepts
3
Batch Processing Using
SAS® under z/OS
Welcome to Batch Processing Using SAS® under z/OS. My name is Michelle and I will be your instructor
for this e-lecture. I have been using SAS since 1988 when it only existed on the mainframe.
Before we begin the lecture, let me take just a minute to point out a helpful reference that’s available to
you. We’ve included a transcript so that you can print all of the information provided in this lecture. To
access the transcript, select Reference and then Transcript in the table of contents on the left side of the
viewer. You can print this transcript now for use when viewing the lecture or print it later to keep as a
reference. We hope you find the transcript to be a useful tool! And now, let’s get started…
U
U
U
U
4
Batch Processing Using SAS® under z/OS
Batch Processing Using SAS® under z/OS
1. Fundamental Concepts
2. Combining and Editing SAS Programs
3. Additional JCL
2
In this lecture we are going to talk about batch processing. Specifically, we are going to see some
fundamental concepts, combining and editing your SAS programs, and some additional JCL.
1. Fundamental Concepts
1.
Fundamental Concepts
Batch Processing Using SAS® under z/OS
1. Fundamental Concepts
2. Combining and Editing SAS Programs
3. Additional JCL
3
So let’s start off with some fundamental concepts.
5
6
Batch Processing Using SAS® under z/OS
Objectives
„
Enter and submit SAS programs in the Interactive System
Productivity Facility/Program Development Facility (ISPF/PDF).
„
Save SAS programs.
„
Use basic job control language (JCL) statements.
„
Copy JCL into your SAS programs.
„
Use the Spooled Data Set Facility (SDSF) or Interactive
Output Facility (IOF) to view your SAS log and SAS output.
4
In this section we are going to use an Interactive System Productivity Facility, also known as ISPF, to edit
and save your SAS programs. We’ll be seeing how you can use some basic JCL (or job control language),
how to copy that JCL into your programs, and then how to submit that code and then view it using the
SDSF or IOF facilities, and then we will purge or release those held output files.
1. Fundamental Concepts
7
Program Development Facility
„
The READY prompt
„
Your development facility menu
„
An alternative menu that enables you to access your
development facility
5
First off, you need to check with your system administrator for a mainframe ID and password and how to
start the software to get to a mainframe signon screen. This information is different at each site. Then
invoke the SPF facility at the ready prompt by simply typing SPF, or at your site it might be ISPF.
8
Batch Processing Using SAS® under z/OS
ISPF Main Menu
6
And that would bring up a menu that looks like this. Now our first job is to edit a program, so we are
going to …
1. Fundamental Concepts
Entering SAS Programs
7
… use option number 2. So we will simply type 2 on the Option line and press ENTER.
9
10
Batch Processing Using SAS® under z/OS
Entering SAS Programs
8
That will bring us to the editor option. Our next goal is to type in what we want to edit. Your MVS
facilities are broken up into projects, groups, types, and then members. The project, group, and type
combined are called a partitioned data set, or PDS. A PDS is like a folder under Windows, and then we
can put files, or what MVS calls members, into that folder. The project name is also known as the highlevel qualifier. So I am going to type in the project name – it is EDU000 – the group of PROG1, the type
of SASCODE, and then I am going to create a new member called BATCH1. If you leave the member
blank, then you will get a list of all of the members within that PDS.
1. Fundamental Concepts
11
Saving the Program
9
Now I can simply type in my SAS program using that editor. So here’s a SAS program that has code you
may already be familiar with. Now when I am ready to save that program, I can just type save on the
Command line.
12
Batch Processing Using SAS® under z/OS
Basic Job Control Language
This section explains the following JCL statements:
„
JOB
„
EXEC
„
SYSIN
10
Now our whole job here is to execute this in batch. To do so, we need to use JCL, or job control language
statements. There are some basic statements that you need to know. They are the JOB statement, the
EXEC statement, and the SYSIN statement.
1. Fundamental Concepts
13
Basic Job Control Language
General form of the JOB statement:
//job-name JOB (acct-info),'name'
job-name
is the unique name for this job. Usually your user ID
plus one character (a-z). Use up to eight alphanumeric
or national (@ $ #) characters. Jobs with the same
name will not run concurrently.
acct-info
(Optional) indicates who to charge for the computer
time used. Use a comma to skip.
name
11
can be a maximum of 20 characters, enclosed in
quotation marks. Printed on banners for this job.
So first of all let’s discuss the JOB statement. You need to start the JOB statement with a slash slash
followed by the name of the job. This is a unique name that you need to use; usually, your user ID plus a
character is used as your job name, but it can be any job name as long as it is a maximum of 8 characters
in length and only has letters, numbers, and the national characters of the at sign, dollar sign, and pound
sign. After you type in the job name, type in a single space and then the keyword JOB. Next, in
parentheses, you can type in your accounting information and then a comma and, within quotes, a
maximum of 20 characters, which is just basically a name that would put a banner on that job.
14
Batch Processing Using SAS® under z/OS
Basic Job Control Language
General form of the EXEC statement:
//step-name EXEC procedure-name
step-name
is the unique name for this step (optional).
procedure-name
is the procedure name used at your location to invoke
SAS (for example, SAS9).
12
Next we’ll need to know the EXEC statement. The EXEC statement also starts with two slashes and then
is the name of a step within this JOB. The step name is optional, but if you have multiple steps within the
job, it is highly recommended you put in your step name so you can find them when you are looking at
your output. Then we are going to code in the keyword EXEC, followed by the procedure name. Now,
this isn’t like a SAS PROC name. This is actually the executable that kicks off SAS on that operating
system. So, for instance, it may be SAS or SAS 9 or whatever executes SAS at your site.
1. Fundamental Concepts
Basic Job Control Language
General form of the SYSIN statement:
//SYSIN DD DSN=
or
//SYSIN DD *
DD
indicates a Data Definition statement.
DSN=
points to the partitioned data set member or other z/OS
file that contains your SAS program.
*
indicates that program code will follow in the same file.
13
Next we are going to have the SYSIN statement. The SYSIN statement can take on one of two forms.
Both forms start with slash slash SYSIN space DD. Then you can either follow it with a DSN, and the
DSN says point to another file on the operating system that contains my SAS program. Or if you say
SYSIN DD asterisk, the asterisk means that my code is going to immediately follow this line.
15
16
Batch Processing Using SAS® under z/OS
Basic Job Control Language
To access your JCL, enter the necessary information.
14
So what I have here is that I am going to put my JCL in a separate member of a partitioned data set and
that way I can copy it into any SAS program that I want to. So in my PDS of EDU000, PROG1,
SASCODE, I am going to type in a member name of JCL, …
1. Fundamental Concepts
17
Basic Job Control Language
15
… and then I will add my JCL. You will see that I have my JOB statement, my EXEC statement, and my
SYSIN DD*. So these are three basic generic statements that I am going to copy in for any SAS program.
18
Batch Processing Using SAS® under z/OS
SYSIN Statement
1. Use DSN= to point to the file that contains your program.
16
continued...
Alternatively, in your JCL you could say SYSIN DD, DSN=EDU000.PROG1.SASCODE, then in
parentheses the name of the SAS program (such as BATCH1), and then that would point to the file that
contains my SAS code.
1. Fundamental Concepts
19
SYSIN Statement
2. Use the SAS macro statement %INCLUDE to bring SAS code
into the SAS session from a file or PDS member.
17
continued...
If I chose to use SYSIN DD *, another way to point to SASCODE is to use a %INCLUDE statement.
%INCLUDE is a SAS statement, not a JCL statement. It is going to say %INCLUDE, then within quotes
the name of your partitioned data set, then in parentheses the member of the partitioned data set that you
want to execute, close quote semicolon. And that would go off to that program and execute that code as if
it existed right here.
20
Batch Processing Using SAS® under z/OS
SYSIN Statement
3. Use DD * to indicate that SAS code follows the JCL statements
in the same file.
18
And once again, alternatively, I could have had the code directly in my program. So after my JCL
statements on the SYSIN DD * I could have the LIBNAME statement, my OPTIONS statements, and any
other SAS code that I want to execute.
1. Fundamental Concepts
21
Copying JCL
19
Alright, so let’s say that I just have my SAS program in a file called BATCH1, and I want to bring in that
generic JCL and put it at the top. So first of all, on line number 1, I want to type B because I want to copy
this JCL before (B for before) the first line. And then on the Command line I will type COPY space and
the name of the member of this same PDS that contains my JCL. So I will say COPY JCL, and that will
bring in that generic code. If your JCL is not in the same PDS as we are currently looking at, you could
say COPY and then, within quotes, point to a different PDS and the member within that PDS.
22
Batch Processing Using SAS® under z/OS
Submitting the Program
20
So now my JCL has been copied in, so we have my generic JCL at the top, including the SYSIN DD *
and the SAS code that follows. To get this code to execute, on the Command line I can type SUBMIT, or
abbreviate that to SUB.
1. Fundamental Concepts
23
Submitting the Program
21
Now I will get a message from the facility saying that the job, whatever you named your job, has been
submitted, and three asterisks. Whenever you see three asterisks in MVS, just press ENTER to continue.
24
Batch Processing Using SAS® under z/OS
Viewing the Log and Output – SDSF
22
Now if you want to take a look at the log and the output, we’re going to use the SDSF facility to get there.
I’m going to return to my main menu screen by pressing F3 on my keyboard until I see the main menu.
So on my command line back in the main ISPF menu, I am going to type M to get to the master
application menu and dot Q to get to the SDSF menu. Now this is specific for my site; your site might be
something different, and you should contact your site administrator to see what it is.
1. Fundamental Concepts
Viewing the Log and Output – SDSF
23
Once I am here, it brings me to the main window, for the SDSF primary options menu, and you can see
on the left hand side we have a number of different options. One is to display the active users. One is to
list the input queue, so if you have a long running job you can see how it is progressing. We’ve got an
output queue and a held output queue. And that is what we are going to do. We are going to the held
output queues, so I am going to type H on the Command line …
25
26
Batch Processing Using SAS® under z/OS
Viewing the Log and Output – SDSF
24
… and that brings me to the list of all of my jobs. So we’ve got the job name and the owner, and it has my
user ID. If you don’t know what options you can type here, you type a question mark next to that job
name, and you will see a list of all the available options.
1. Fundamental Concepts
27
Viewing the Log and Output – SDSF
25
One of those options is to display all of the components of the job. So we’ve got the components of the
log and the list, as well as the JCL information. So like a good SAS programmer, I want to take a look at
the log. So next to where it says SASLOG, I am going to type S. S stands for select.
28
Batch Processing Using SAS® under z/OS
Viewing the Log and Output – SDSF
26
And that would select just the log itself, and I can take a look and identify any error messages, warning
messages, or notes that look unusual. In this case, everything looks like normal notes, so that should be
good. So I can hit my F3 key or type END on the Command line.
1. Fundamental Concepts
29
Viewing the Log and Output – SDSF
27
And that would return me to viewing the log and the output. Now if I want to take a look at the output
itself, that is under the SASLIST portion. So now I’ll type S (for select) next to the SASLIST component.
30
Batch Processing Using SAS® under z/OS
Viewing the Log and Output – SDSF
28
And that would show me the output generated from my SAS program – in this case, output from a PROC
MEANS. Once you are done looking at the output, press F3 or again type END on the Command line …
1. Fundamental Concepts
31
Submitting Another Program
1. Access an Edit Entry Panel (using ISPF 2).
29
continued...
… which will return you to the main ISPF menu. Usually at this point, I want to edit my program because
it didn’t work or I want to create an additional program. So back at the ISPF edit menu, I am going to go
to that same project, group, and type, (the same PDS) and type in a new member name. I will creatively
call it BATCH2.
32
Batch Processing Using SAS® under z/OS
Submitting Another Program
2. Enter the SAS program.
30
continued...
Then I will enter my program that I want it to execute, so here I am writing PROC TABULATE code, …
1. Fundamental Concepts
33
Submitting Another Program
3. Copy the JCL before the SAS program.
31
continued...
… and then I want to bring in that same generic JCL. So then I will type B on line number 1, and then on
the Command line type COPY JCL.
34
Batch Processing Using SAS® under z/OS
Submitting Another Program
4. Issue the SUBMIT command.
32
And that brings my generic JCL up along the top. Then I can issue the SUBMIT command, or SUB, to
submit the program.
1. Fundamental Concepts
35
Viewing the Log and Output – IOF
The IOF facility is another way to view your log and output.
To access IOF, type I on the command line and press ENTER.
Here are some useful IOF commands:
B – Browse entire job as a single file
C – Cancel (deletes the file, similar to Purge in SDSF)
PC – Show why job will not print
S – Select for review
33
Now an alternative way besides the SDSF facility is to go into the IOF facility to look at our log and our
output. Once again getting to the IOF facility is dependent on what your site is. So contact your site
administrator to see what it is at your site. Once you find the IOF Job List Menu, then you will once again
see your JOBNAME and user ID. Then we can type an S for select, a B to browse the entire job as a
single file, or a C to cancel, which will delete the file. And if your job is not printing ,you can type PC to
show why the job will not print. So we are going to type in an S.
36
Batch Processing Using SAS® under z/OS
Viewing the Log and Output – IOF
34
This is going to look very similar to what we had before. We see a breakout of all the different
components of my job, specifically the SASLOG, the SASLIST, and the different JCL. So if I type S for
select next to SASLOG, …
1. Fundamental Concepts
37
Viewing the Log – IOF
35
… then we can verify the log and check for any errors, warnings, or notes that look unusual. Once you are
done reviewing, hit F3 or type END on the Command line.
38
Batch Processing Using SAS® under z/OS
Viewing the Output – IOF
36
Then you can type S next to your SASLIST and view the output; so here is my output from PROC
TABULATE. Once again, after you are done reviewing the output, just hit F3.
2. Combining and Editing SAS Programs
2.
Combining and Editing SAS Programs
Batch Processing Using SAS® under z/OS
1. Fundamental Concepts
2. Combining and Editing SAS Programs
3. Additional JCL
37
Now that you have an idea of how to submit your SAS programs using batch, let’s talk about how you
can combine and edit your SAS programs together.
39
40
Batch Processing Using SAS® under z/OS
Objectives
„
Combine your SAS programs.
„
Edit your SAS programs.
„
Purge (release) held output files.
38
So we are going to combine our SAS programs and then edit our SAS programs.
2. Combining and Editing SAS Programs
Combining SAS Programs
„
Use multiple DSN= parameters.
„
Use multiple %INCLUDE statements.
„
Copy the steps into one file and edit it.
39
Specifically, we are going to see how you can use multiple DSN parameters, use multiple %INCLUDE
statements, and copy the steps from one file to another and edit it.
41
42
Batch Processing Using SAS® under z/OS
Multiple DSN= Parameters
40
So here I’ve got some JCL, a JOB statement, and an EXEC statement. And my SYSIN DD statement is
pointing to a DSN of EDU000.PROG1.SASCODE and, in parentheses, the member name of my SAS
program, which is BATCH1. We haven’t talked about this before, but notice there is a comma and a
DISP=SHR. SHR stands for share, which means read-only, and that is what you’ll want when you are
reading your SAS programs.
2. Combining and Editing SAS Programs
43
Multiple DSN= Parameters
41
Now what I am going to do is augment that SYSIN statement by adding another slash slash and a DD.
Notice that my DD does line up with the first DD on line three. This isn’t necessary, but it does make it
easier to read. The only part that is necessary is that there is at least one space between the slash and DD.
Then I will write another DSN EDU000.PROG1.SASCODE and, in parentheses, that SAS program called
BATCH2 and once again the DISP=SHR. And I can code as many of these DDs as I need to, and this is
called a concatenated DD statement, where we are just coding separate programs on different lines.
44
Batch Processing Using SAS® under z/OS
Multiple %INCLUDE Statements
42
As we saw earlier, we could use a SYSIN DD* with a %INCLUDE, and the %INCLUDE would point to
a single SAS program.
2. Combining and Editing SAS Programs
Multiple %INCLUDE Statements
43
You could of course then simply have multiple %INCLUDEs to point to more than one SAS program
file.
If your stored program contains JCL (or if you do not know if the program contains JCL), use the
JCLEXCL option in the %INCLUDE statement.
45
46
Batch Processing Using SAS® under z/OS
Copying Steps
44
continued...
What we are going to do now is copy in some steps. I have already gone into edit mode to create a new
program, called EDU000.PROG1.SASCODE, and in parentheses BATCH3, so this is just an empty file.
Then on the Command line, I am going to type COPY BATCH1.
2. Combining and Editing SAS Programs
47
Copying Steps
45
And that brings in whatever was in the member of BATCH1, which was my JCL followed by my SAS
program. Now I want to copy in additional code, and I want to copy it to the bottom of this program. So
on line number 9, I am going to type A (A stands for After) because I want to copy the new code after line
number 9. Then on the Command line, I am going to type COPY and the name of that member, BATCH2.
Once again this assumes that this is in the same PDS that we are currently sitting in,
EDU000.PROG1.SASCODE. If you want to copy it from a different PDS, say COPY, then in quotes the
name of that PDS, and then in parentheses the member of that PDS.
48
Batch Processing Using SAS® under z/OS
Text Editor Line Commands
Line commands:
In
Insert n lines
Dn
Delete n lines
Cn
Copy n lines
Mn
Move n lines
Rn
Repeat n lines
A
After (designates C, I, and M text destination)
B
Before (designates C, I, and M text destination)
46
Now we have talked about A for after and B for before. In addition, there are other line commands that
you might be interested in. If you want to insert a line into a program, then on the line numbers, you
would type I. If you want to insert 5 lines, type I5 and then press ENTER. To delete a line, type D. To
delete 5 lines, type D5. If you want to repeat a line – so basically a copy immediately after – then type R
for repeat. R3 would repeat it three times. To copy a line, you use C. To move a line, you use M.
Whenever you use copy or move, you do need to use the A for after and B for before.
2. Combining and Editing SAS Programs
49
Text Editor Block Commands
Block commands:
DD
Delete block start / end
CC
Copy block start / end
MM
Move block start / end
RR
Repeat block start / end
A
After (designates CC and MM text destination)
B
Before (designates CC and MM text destination)
47
Now if there is a large number of lines that you want to copy or move or delete, then you can use the
block commands. So if you want to delete a large number of statements, type DD on the first statement
that you want to delete and DD on the last statement that you want to delete, so you are blocking those off.
Then when you press ENTER, all those statements between the DDs, including the first and last
statement, do get deleted. Likewise, if you want to copy a block, put CC on the first line you want to copy,
CC on the last line you want to copy, and then A to copy it after a given line or B to copy it before a given
line. Then use MM for move and the RRs to repeat a block.
50
Batch Processing Using SAS® under z/OS
Copying Steps
Use a block delete (DD) command.
48
So once I have copied in that new program, that program had that JCL as well, and I certainly don’t need
that JCL twice in my program. So I am going to put DD on line number 10 and DD on line number 13.
Once I type those in and press ENTER, those lines will be deleted.
2. Combining and Editing SAS Programs
Editing Your Program
Use the insert (I) command.
49
Now if I want to insert a new line after line number 14, I can type an I, so the default is to insert a line
after the line that you are currently sitting on. So when I type I and press ENTER, …
51
52
Batch Processing Using SAS® under z/OS
Editing Your Program
50
… I will get an empty line, and then I can type in whatever additional program that I want, such as a
TITLE2 statement.
2. Combining and Editing SAS Programs
53
Editing Your Program
Move lines with the block move (MM) command and the after (A) command.
51
To move the PROC MEANS below the PROC TABULATE, I am going to type MM on line number 6. I
am going to start the block move so that is the first line I want to start moving, and an MM on line number
9. So I am going to move that entire block from line 6 through 9. When you use MM or CC, you still need
to use after or before. So on line number 16, I am going to type A for after, which is going to move lines 6
through 9 after line 16. Make sure you press the ENTER key to complete the action.
54
Batch Processing Using SAS® under z/OS
Editing Your Program
52
Now we can see that the PROC MEANS has been moved to after the PROC TABULATE.
2. Combining and Editing SAS Programs
Submitting the Combined SAS Program
53
Now that I have it in the order that I want, I am going to type SUBMIT or SUB on the Command line.
55
56
Batch Processing Using SAS® under z/OS
Viewing the Results
54
Using whatever facility I like, I will check the log, and we see that the log shows the PROC TABULATE
followed by the PROC MEANS and that looks great. If your log is long, you may want to type the words
Find ERROR on the Command line to search for errors in the log.
2. Combining and Editing SAS Programs
Viewing the Results
55
Then I will check my output, and we will see the output from PROC TABULATE. And if I scroll down
using my F8 key, we will see the output from PROC MEANS. So if you want to scroll, it’s F8 to scroll
down and F7 to scroll up.
57
58
Batch Processing Using SAS® under z/OS
Releasing Held Files
56
Now we have been running a lot of programs, so I need to start cleaning up my held files. So if I am in
my SDSF facility, you will see a list of all of your jobs, and to get rid of your jobs, just type P for purge
next to each job name. If you are in the IOF facility, you would type C next to the job. C stands for
Cancel.
3. Additional JCL
3.
Additional JCL
Batch Processing Using SAS® under z/OS
1. Fundamental Concepts
2. Combining and Editing SAS Programs
3. Additional JCL
57
So what we have shown you up until this time is some basic JCL.
59
60
Batch Processing Using SAS® under z/OS
Objectives
„
Write more complex JCL statements.
„
Better understand JCL syntax.
58
Let’s take a look at some more advanced JCL. We’re going to talk about some more complex JCL
statements, so you’ll get a better understanding of the JCL syntax.
3. Additional JCL
JCL Syntax
Start
1
Stop
71
Record
Length
80
//MYRAW DD DSN=EDU000.PROG1.RAWDATA,DISP=SHR
59
continued...
The JCL, for the most part, is always going to start in column number 1 and stop in column number 71,
and the maximum record length can be 80.
61
62
Batch Processing Using SAS® under z/OS
JCL Syntax
All uppercase
//MYRAW DD DSN=EDU000.PROG1.RAWDATA,DISP=SHR
Usually begin with two slashes (//) except the following:
„
JOBPARM and Delimiter statements, which begin with a slash and
an asterisk (/*)
„
comments, which begin with two slashes and an asterisk (//*)
60
continued...
Your JCL syntax, for the most part, is going to start with slash slash in columns 1 and 2, followed by all
of the rest of the information, which must be in uppercase. The only exception to starting with two slashes
is the JOBPARM and Delimiter statements, which begin with a slash and an asterisk (/*), and the
comment, which starts with two slashes and then an asterisk (//*).
3. Additional JCL
63
JCL Syntax
Two
slashes
and then
a space
//job-name JOB (acct-info),'name',CLASS=a,
// NOTIFY=user-ID,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
Continuation
comma
61
continued...
We talked about the JOB statement, so you say slash slash and then the name of the job immediately
following it. If, however, that JOB statement or any statement spans multiple lines, at the end of the first
statement, you would use a comma – and that’s called a continuation comma – and then on the next line,
you would code those two slashes again, and then at least one space. After the space or spaces, you can
continue on with whatever continues on that statement. This information must start between columns 4
and 16 and go no further than column 71.
64
Batch Processing Using SAS® under z/OS
JCL Syntax
//job-name JOB (acct-info),'name',CLASS=a,
// NOTIFY=user-ID,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
Sub-parameter
list
// MSGLEVEL=(,d),REGION=k,TIME=(m,s)
Omitting first
parameter
Single
Parameter
62
Many of the pieces of your JCL statements will also contain parameters, or a sub-parameter list. Your
sub-parameter list is enclosed within parentheses, and the parameters themselves are separated by
commas. If you want to omit the first parameter, just put in a comma, and then the second parameter. If
there is just a single parameter, or you just want to code the first parameter, you don’t need to put in the
parentheses. If the last parameter is omitted, you do not need a comma as a placeholder.
3. Additional JCL
65
JOB Statement
//job-name JOB (acct-info),'name',CLASS=a,
// NOTIFY=user-ID,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
job-name
is the name for this job – typically, your user ID plus one
character (A-Z). Can be any combination of 8 or fewer
alphanumeric and @ $ # characters.
acct-info
is information to identify the person or group to be charged
for the computer resources used by this job.
63
continued...
So, the JOB statement, as we discussed earlier, is slash slash, the name of the job, the keyword JOB, and
then, in parentheses, your accounting information. Your accounting information is site specific, so check
with your systems administrator, or do like the rest of us do and just find someone’s JCL to copy!
66
Batch Processing Using SAS® under z/OS
JOB Statement
//job-name JOB (acct-info),'name',CLASS=a,
// NOTIFY=user-ID,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
name
is the name (1-20 characters) that will be printed on the
banner of the job's output. Enclose the text in single
quotation marks.
CLASS=
is the queue for this job, as defined by your system
administrator. Some queues run jobs at specified times;
others might cancel jobs that use too many CPU seconds.
64
continued...
Next we have the name, which is going to be the banner, enclosed within quotes, and that can be up to 20
characters long. And then additional information in the JOB statement can include the CLASS= option.
The CLASS= option is the queue for this job, as defined for your system administrator. Some system
administrators might define a queue as “this queue is specifically for quick-running jobs” or “this queue is
for long-running jobs” or “this queue is for high priority jobs,” so check with your systems administrator
to find out the names of the different classes for those queues.
3. Additional JCL
JOB Statement
//job-name JOB (acct-info),'name',CLASS=a,
// NOTIFY=user-ID,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
NOTIFY=
indicates that this user will be notified via broadcast message
when the job finishes. The symbolic parameter &SYSUID can
be substituted here.
MSGCLASS=
designates the output queue (site specific).
65
continued...
The NOTIFY= option says to broadcast a message to this user ID when the job finishes. You can
hardcode your user ID, or use the symbolic parameter &SYSUID to be your user ID.
The MSGCLASS= option designates the output queue to send it to. Once again, check with your site
administrator for your specific message classes.
67
68
Batch Processing Using SAS® under z/OS
JOB Statement
//job-name JOB (acct-info),'name',CLASS=a,
// NOTIFY=user-ID,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
MSGLEVEL=
The first parameter controls printing of JCL:
0 – No JCL messages
1 – All JCL messages
2 – All JCL messages, except from cataloged
procedures
66
The second parameter controls data set allocation / disposition messages:
0 – No allocation messages unless the job abends
1 – All allocation messages
continued...
The MSGLEVEL= option has two parameters. The first parameter controls the printing of your JCL. If
you code a 0 as your first parameter, that says “don’t print out any JCL messages.” A value of 1 says
“print out all JCL messages” and 2 says “all JCL messages except from cataloged procedures.” The
second parameter controls your data set allocation or disposition messages. 0 means “don’t print any
messages unless the job abends” – and abend stands for abnormal end. A 1 means “print out all allocation
messages, regardless of how the job performs.”
3. Additional JCL
JOB Statement
//job-name JOB (acct-info),'name',CLASS=a,
// NOTIFY=user-ID,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
REGION=
specifies the amount of storage a job can use in kilobytes
or megabytes (for example, 2K or 5M).
67
continued...
The REGION= option specifies the amount of storage a job can use. This is going to be in kilobytes or
megabytes, so you could say something like 2K or 5M.
69
70
Batch Processing Using SAS® under z/OS
JOB Statement
//job-name JOB (acct-info),'name',CLASS=a,
// NOTIFY=user-ID,MSGCLASS=b,
// MSGLEVEL=(n,d),REGION=k,TIME=(m,s)
TIME=
The first parameter controls the total CPU minutes that
the job is allowed to run.
The second parameter controls the total CPU seconds
that the job is allowed to run.
68
And then the TIME= option is the estimated time you expect this program to run. The first parameter is
the total CPU minutes, and the second parameter is the total CPU seconds that the job is allowed to run.
3. Additional JCL
71
OUTPUT Statements
//form-name OUTPUT DEST=dest-ID,
// COPIES=x
form-name
can be a maximum of eight alphanumeric and national
(@ $ #) characters. Must start with a letter or national
character.
DEST=
specifies the destination printer ID.
69
continued...
You can also use an output JCL statement. The output JCL statement is going to start with slash slash and
the name of a form. This is a maximum of eight characters, letters, numbers, and those three alphabetic or
national characters (@$#). It must start with a letter or a national character, then the keyword OUTPUT
and then DEST= and your destination printer ID.
72
Batch Processing Using SAS® under z/OS
OUTPUT Statements
//form-name OUTPUT DEST=dest-ID,
// COPIES=x
COPIES=
specifies the number of copies of the output to print.
70
Continuing on this OUTPUT statement, you can use the COPIES= option, and that specifies how many
copies of the output to print.
3. Additional JCL
73
JOBPARM Statements
/*JOBPARM DEST=dest,NAME='form-name',COPIES=x
DEST=
specifies the destination printer ID.
NAME=
can be a maximum of eight alphanumeric and national
characters (@ $ #); the value cannot start with a number.
COPIES=
specifies the number of copies of the output to print.
71
The JOBPARM statement is one of those unusual JCL statements that you may see in your JCL, because
it starts with a single slash followed by an asterisk. Then the words JOBPARM DEST= and a destination
printer ID, NAME= and the form name, and COPIES= and the number of copies. So this is an alternative
to that OUTPUT statement.
74
Batch Processing Using SAS® under z/OS
JOBPARM Statements
/*JOBPARM FETCH
FETCH
holds the job output in an output queue.
72
You can also put /*JOBPARM and then the keyword FETCH, and FETCH says “don’t actually print it,
just hold it in the job output queue” and gives you the ability to print it at will.
3. Additional JCL
EXEC Statement
//step-name EXEC proc|PGM=prog,
// REGION=k,TIME=s
step-name
is the identifier name for this step (optional).
proc
is a cataloged procedure (for example, SAS9).
PGM=
specifies an application program name.
73
continued...
Now the EXEC statement, which we talked about briefly earlier, you say slash slash, then I recommend
you put in the name of a step, then a space, then the keyword EXEC, and then the PROC name, such as
SAS9. Alternatively, you can also use PGM= and an application program name.
75
76
Batch Processing Using SAS® under z/OS
EXEC Statement
//step-name EXEC proc|PGM=prog,
// REGION=k,TIME=s
REGION=
is the amount of storage that this step can use in Kbytes
or Mbytes (for example, 2K or 5M).
TIME=
is the total CPU seconds that this step is allowed to run.
74
Other options that can go in the EXEC statement include the REGION= option, and this is the amount of
storage that this step can use in kilobytes or megabytes, so this is step-specific if you have multiple steps
within the same job.
The TIME= option is the total CPU seconds that this step is allowed to run. So we saw the TIME= option
in the JOB statement, which was how much time was allocated to the whole job, and if you have multiple
steps within the job, you can control how much time in seconds is allocated to the step.
3. Additional JCL
DD Statements for Existing Data Sets
//ddname DD DSN=project.group.type,
// DISP=disp
ddname
is the alias for the file specified in this DD statement.
DSN=
indicates the data set to use, such as a sequential file,
PDS, or PDS member (member name in parentheses).
75
continued...
For the DD statements, we saw slash slash, a name, DD and DSN= some value. Previously, we saw
SYSIN as the DD name, but this can be some other DD name as well, something that you can specify.
77
78
Batch Processing Using SAS® under z/OS
DD Statements for Existing Data Sets
//ddname DD DSN=project.group.type,
// DISP=disp
DISP=
is the disposition for the file:
„
SHR (share – multiple users, read-only)
„
OLD (single user, write access).
76
The DISP= option is going to have the value of either SHR, which means multiple users and read-only, or
I can also have the value of OLD, which means I have exclusive read/write access to this particular file,
and that’s what you would code for existing data sets.
3. Additional JCL
79
DD Statements for New Data Sets
//ddname DD DSN=project.group.type,
// DISP=(d,n,a),SPACE=(t,(p,s),r),
// UNIT=u,VOL=SER=v
DISP=
First parameter – Disposition for the file:
„
NEW (DEFAULT – create a new file)
„
MOD (if file exists, write over it; if not, create it)
Second parameter – Action if job finishes normally.
Third parameter – Action if job abends.
77
Valid values for second and third parameter include CATLG
and DELETE.
continued...
You can also use JCL to create brand new members within a PDS, or a brand new PDS, or a brand new
sequential file. So to do so, after the DSN you would code a comma, and then the next option is the
DISP= option. Instead of saying OLD or SHR, we are going to have parentheses and three different
parameters. The first parameter is going to be NEW, saying “I want to create a new file.” Or, the first
parameter could be MOD, saying “modify an existing file. If it doesn’t exist, then go ahead and create it.”
The second parameter is what action to perform if the job finishes normally, such as CATLG, and the
third parameter is what action to perform if the job abends, or abnormally ends. Often the third parameter
option is DELETE.
80
Batch Processing Using SAS® under z/OS
DD Statements for New Data Sets
//ddname DD DSN=project.group.type,
// DISP=(d,n,a),SPACE=(t,(p,s),r),
// UNIT=u,VOL=SER=v
SPACE=
First parameter – Units for space allocation: TRK, CYL, or block size.
Second parameter – Number of units needed for primary extent.
Third parameter – Number of units for each secondary extent.
Last parameter (optional) – If coded (RLSE), unused space is released
to the system at the end of the job.
78
continued...
Next, because this is a brand new data set, we need to specify how much space we would like to give it,
so we’re going to use the SPACE= option. The first parameter for the SPACE= option is how many units
to allocate. That’s specified in tracks, cylinders, or blocks. The second parameter goes inside a
parentheses, so these are sub-parameters within that, and that is the number of units needed for the
primary extent. So: ”How much am I going to give it from the get-go?”
The third parameter is the number of units for the secondary extent, and that’s the “well, if I guessed
badly for the primary extent, try extending it by this much more.” In general, the system will continue to
extend your secondary amount up to 15 times.
And the last parameter is optional. If used, the value is RLSE as the parameter value, and that says
“release any unused space back to the system at the end of the job.”
3. Additional JCL
81
DD Statements for New Data Sets
//ddname DD DSN=project.group.type,
// DISP=(d,n,a),SPACE=(t,(p,s),r),
// UNIT=u,VOL=SER=v
UNIT=
is the device type.
Examples:
79
„
380
„
SYSDA
VOL=SER=
is the volume to which the data set is written. If not
specified, the system chooses a volume with space
available.
The UNIT= option is the device type I want to store this on, such as UNIT=380 (so a 380 device type) or
UNIT=SYSDA, for system direct access, which is a common name.
The VOLSER= option, which is VOL=SER=, is used if you want to write it to a specific volume and you
know the name of that volume, you can specify the name of the volume here.
82
Batch Processing Using SAS® under z/OS
DD Example: Creating a File
//NEWFILE DD DSN=USERID.NEW.FILE,
//
DISP=(NEW,CATLG,DELETE),
//
SPACE=(CYL,(5,2),RLSE),
//
UNIT=SYSDA,VOL=SER=SAS900
80
continued...
So, putting this all together, I’m going to create a new file, and I’m going to give it a DD name,
specifically NEWFILE DD DSN=, and I’m actually going to code my USERID dot NEW dot FILE.
Then for the DISP= option, I’m going to say “create it new. If the job terminates normally, catalog it; if
the job terminates abnormally, delete this file.”
3. Additional JCL
83
DD Example: Creating a File
//NEWFILE DD DSN=USERID.NEW.FILE,
//
DISP=(NEW,CATLG,DELETE),
//
SPACE=(CYL,(5,2),RLSE),
//
UNIT=SYSDA,VOL=SER=SAS900
81
I would like to give it space in cylinders, so I’m going to give it 5 primary cylinders. If that’s not enough,
start giving it 2 additional cylinders up to a total of 30 additional cylinders (2 times 15 is 30), and then
release any extra space at the end of the job.
The UNIT= is the common SYSDA device, and I know I want to write it specifically to a disk pack called
SAS900, so the VOLSER=SAS900.
84
Batch Processing Using SAS® under z/OS
DD Example: Concatenating Files
//FLATFILE DD DSN=USERID.FILE1.DATA,DISP=SHR
//
DD DSN=USERID.FILE2.DATA,DISP=SHR
//
DD DSN=USERID.FILE3.DATA,DISP=SHR
82
We can also use concatenated files. So let’s say I have three raw data files out there – that’s my user ID
dot FILE1.DATA, my user ID dot FILE2.DATA, and my user ID dot FILE3.DATA. I can use the
concatenated DD statement to put all three of those DSNs together to create a single name called
FLATFILE.
3. Additional JCL
85
DD Example: Rerouting SAS Log and Output
//SASLOG DD DSN=USERID.FILE.LOG,DISP=OLD
//SASLIST DD DSN=USERID.FILE.LIST,DISP=OLD
83
If you want to reroute your SAS log and output to specific filenames instead of looking them up in your
IOF or other facility, you can specifically use DDs of SASLOG and SASLIST. Code a slash slash
SASLOG DD DSN= and the location that you want to route your log to. Since you are going to be writing
something, you want to use the DISP=OLD option. Remember DISP=OLD says I have exclusive
read/write access to this location. And likewise, you can redirect your output by using the SASLIST DD,
and once again, the DISP=OLD option.
86
Batch Processing Using SAS® under z/OS
DD Example: SYSIN
//SYSIN
//
//
//
DD DSN=EDU000.PROG1.SASCODE(C02S2D1),
DISP=SHR
DD DSN=EDU000.PROG1.SASCODE(C02S2D2),
DISP=SHR
84
As we saw earlier, we can concatenate multiple programs together by putting a concatenated DD in the
SYSIN statement.
3. Additional JCL
87
DD Example: Creating a Libref in JCL
//IA DD DSN=MYUSER.PROG1.SASDATA,DISP=OLD
85
Now typically, we have been using a LIBNAME statement in our SAS programs to point to a SAS data
library on our machine. There is an alternative approach. You actually can use a libref in your JCL. So if I
want to create a libref of IA, I can say slash slash IA DD DSN= and then put in the SAS data library
location, such as MYUSER.PROG1.SASDATA. I might be creating new data sets into that library, so
I’ll use the DISP=OLD option. If you’re just going to be reading data from that library, feel free to use the
DISP=SHR option.
BY coding this with JCL, that will create my libref, and my SAS program can then use a libref of IA.
88
Batch Processing Using SAS® under z/OS
DD Example: Creating a Libref in JCL
//IA DD DSN=MYUSER.PROG1.SASDATA,DISP=OLD
LIBNAME IA 'MYUSER.PROG1.SASDATA';
86
If you were to code this same libref using a SAS LIBNAME statement instead of JCL it would be
LIBNAME IA 'MYUSER.PROG1.SASDATA';. OLD is the default disposition for a LIBNAME
statement. If you wanted a dispostion of share, you would code DISP=SHR before the semicolon.
The main difference of using JCL versus using a LIBNAME statement is if somebody else is using that
SAS data library, and I’ve got a DISP=OLD option on there, my job will wait until that library is
available. Then once that library becomes available, this job will continue to execute. If instead I had used
a LIBNAME statement, when SAS goes out to query that library to see if it’s available, if it’s not
available, it just says “ump...too bad,” gives up and goes home, and so your job will not terminate
normally.
Another advantage of using JCL is that if there is a typo in the data name, you get an instantaneous JCL
error. If you have a typo in the LIBNAME statement, you may have to wait a long time as your job waits
in a queue for execution time, to eventually fail due to the typo.
3. Additional JCL
DD Example: Using a LIBREF and FILEREF
//IA DD DSN=&SYSUID..PROG1.SASDATA,DISP=OLD
//MYRAW DD DSN=EDU000.PROG1.RAWDATA,DISP=SHR
DATA IA.NEW;
INFILE MYRAW;
INPUT @1 PRODUCT $12. @15 DATE MMDDYY10.;
RUN;
87
If you are reading data from a raw data file, you can use a DD statement. So here I’m going to create a
DD name called MYRAW pointing to EDU000.PROG1.RAWDATA. Then within my SAS program, I
can use MYRAW in my INFILE statement and point directly to that. So, that’s an alternative to a
FILENAME statement, if you’ve ever used a FILENAME statement within SAS.
89
90
Batch Processing Using SAS® under z/OS
Resources for Further Study
„
SAS OnlineDoc, SAS® 9.1.3 Companion for z/OS on the Web
at support.sas.com/onlinedoc/913/
„
Introduction to the New Mainframe: z/OS Basics, Chapter 6,
“Using JCL and SDSF,” on the Web at
publibz.boulder.ibm.com/zoslib/pdf/zosbasic.pdf
„
z/OS JCL Fifth Edition – Gary Deward Brown
88
If you want additional documentation on the MVS or z/OS operating system, you can check SAS
OnlineDoc, the Introduction to the New Mainframe: z/OS Basics from that Web site, or I also recommend
the z/OS JCL Fifth Edition book by Gary Deward Brown.
3. Additional JCL
Credits
Batch Processing Using SAS® under z/OS was developed by Michelle
Buchecker. Additional contributions were made by Brian Gayle, Mark
Jordan, Travis Masters, Kent Reeve, and Jim Simon.
89
Thank you for attending the Batch Processing Using SAS® under z/OS. My name is Michelle.
91
92
Batch Processing Using SAS® under z/OS
Comments?
We would like to hear what you think.
„
Do you have any comments about this lecture?
„
Did you find the information in this lecture useful?
„
What other e-lectures would you like SAS to develop in the future?
Please e-mail your comments to
[email protected]
Or you can fill out the short evaluation form at the end of this lecture.
90
If you have any comments on this e-lecture, please e-mail [email protected].
3. Additional JCL
Copyright
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.
Copyright © 2009 by SAS Institute Inc., Cary, NC 27513, USA.
All rights reserved.
91
Thank you for your time.
93
94
Batch Processing Using SAS® under z/OS