文档库 最新最全的文档下载
当前位置:文档库 › EG 4.2 and SAS CONNECT Mainframe Project which Makes the Mainframe Behave Like a Modern Computer

EG 4.2 and SAS CONNECT Mainframe Project which Makes the Mainframe Behave Like a Modern Computer

Paper 106-2010

A SAS? Enterprise Guide? 4.2 and SAS/CONNECT? Mainframe Project which

Makes the Mainframe Behave Like a Modern Computer

John Hennessey, Mathematical Statistician,

Office of Research, Evaluation, and Statistics,

The Social Security Administration, Woodlawn, MD

ABSTRACT

For those SAS Users who, like us, want to use Enterprise Guide? and SAS/Connect? as your interface to a mainframe, but, do not own SAS Integration Technologies, we present here a self-contained Enterprise Guide? project that can be used. It is available from me at my email address below. It is written for the new version of Enterprise Guide?, version 4.2. In addition to the blank Process Flow Page, it contains a Utilities Process Flow Page with 10 code templates for performing certain SAS/Connect? tasks between Enterprise Guide? and SAS on the mainframe. The tasks have mainframe ID and password prompts already attached. When you start a project which involves the mainframe, you first open this project and immediately do a “save as” to an actual project name. Then, as needed, you copy & paste these code tasks from the Utilities page into the actual process flows of the project. The prompts are preserved when copied from one process flow to another in the same project. Some of the tasks even submit a batch job directly from Enterprise Guide? to the mainframe batch queue and email you back your log and output, as an RTF, PDF, or XLS file.

KEYWORDS & PHRASES

Guide?

? Enterprise

? SAS/Connect?

? Mainframe

? RSUBMIT

THE UTILITY PROCESS FLOW

As you can see in the upper right Project Tree window of Figure 1, there are two Process Flows in the project. The one labeled Process Flow is the regular blank starter process flow. The other one, labeled Utilities, is the one that contains all of the template tasks and is shown in the screenshot. The first program icon signs you on to the mainframe and assigns all of your mainframe libraries for your project. The second icon signs you on to the mainframe and assigns DB2 databases to your project. The third icon signs you off of the mainframe. The next row contains the top and bottom code for an RSUBMIT sandwich. The first icon in the third row is a template for a batch run on the mainframe which emails you back your log and your output as a WORD document. The next icon in that row FTPs your batch program to the mainframe batch queue. The third icon emails your batch results from a previous run to you without running it again. The first icon in the final row signs on to a server and has the server signon to the mainframe and download a dataset. This approach gets your PC out of the middle of the download process. It is especially useful for large datasets. The final icon downloads an entire PDS of programs from the mainframe to a server.

The small question marks in the upper right hand corner of 5 of the icons indicate that those icons have prompts attached. These prompts will ask you for your mainframe ID and/or your password. Prompts in Enterprise Guide? 4.2 are SAS macro variables. They were called parameters in early versions of Enterprise Guide?. Also, in this version of Enterprise Guide?, the passwords are scrambled in your log, if you choose the option to hide them when you create them.

If you email me at my email address below, I will email you the Utilities.egp file which contains all of these tasks in the project.

Figure 1 - Utilities Process Flow in the Utilities Project

ICON DETAILS

“LOGON MAINFRAME” ICON

The First icon on the Utilities Tab contains the following code:

options comamid=tcp;

%let SSSS= MainframeSpawnerName;

signon SSSS.Spawner user='????' password=”&password”;

*libname xxxxxx remote 'xxx.xxxxx.xxxxxx' server= SSSS.Spawner;

*libname yyyyyy remote ‘yyy.yyyyyy.yyyyy’ server= SSSS.Spawner;

*libname zzzzzz remote ‘zzz.zzzzzz.zzzzz’ server= SSSS.Spawner;

Enter the actual name of your mainframe spawner. Replace the ?’s in the “user=’????’ with your mainframe userid. Enter the libnames for the appropriate libraries on the mainframe. As you start different Enterprise Guide? projects from this project template, you can un-comment the desired libname statements and un-comment/enter new ones for the new project. You will notice that all of these program icons are embedded in the Enterprise Guide? project, so the changes you make will be unique to the given project.

The password prompt (parameter/macro variable) has been added to the icon. When you copy & paste this icon to another Process Flow tab in this project, the prompt will also be copied. In Enterprise Guide? version 4.2, the password will automatically be scrambled in the log since we are hiding the value when entered.

All of your required SAS libraries on the mainframe and servers and PC are now in your Enterprise Guide? Server list. You can now drag & drop any of the datasets in these libraries into your Process Flow and Query, Join, Summarize, Analyze, etc. any of them directly in Enterprise Guide?. Their home is transparent to you. “LOGOFF MAIN” ICON

The “logoff main” icon simply contains the code:

signoff SSSS.Spawner;

If you no longer need access to the mainframe while you do other things in the project that will take time, you can use this to politely signoff the mainframe and stay in the project.

“LOGON MAIN DB2” ICON

This code signs you on to the mainframe and assigns a DB2 database as a SAS library which will show up in your Server list in Enterprise Guide?. Of course, you can add additional library assignments to the code.

options comamid=tcp;

%let db2sub=xxxx;

%let SSSS= MainframeSpawnerName;

options remote=SSSS.Spawner;

filename rlink 'S:\xxxx\tcptso.sas';

signon SSSS.spawner;

libname xxxxx rengine=db2 server= SSSS.spawner

roptions='ssid=xxxx authid=xxxxx';

DB2 databases need a “utility” file assigned before you invoke SAS. In this case, it is done with the creation of the macro variable, db2sub, and the use of a logon script, tcptso.sas, provided by SAS. Thus, the original, simpler, signon code without a logon script in the first icon will not work.

If you are familiar with DB2 databases, then the ROPTIONS should be familiar. The SSID = the name of the utility file = the value of DB2SUB. The AUTHID = the name of the DB2 database.

“TOP CODE” AND “BOTTOM CODE” ICONS

The only question now is: where do you want the processing to take place? Which CPU “Brain” do you want to use? If the data sets are small, who cares! If they are large, then the usual rule of thumb is to use the brain which sits next to most of the data. If the data resides on the mainframe, then the appropriate RSUBMIT sandwich for

SAS/CONNECT? to surround your SAS Code must be created. Further, you should create a scratch file on the mainframe to capture your ODS output. It should be a fixed block file with a record length of 80. We will assume the name is xxxx.xxxx.output.

Since you have already signed on to the mainframe, there is no more need to signon. The Top Code Icon for your RSUBMIT sandwich is:

Rsubmit SSSS.Spawner;

/* Conditionally delete a table or view, if it exists */

/* If the member does not exist, then no action is performed */

%macro _eg_conditional_dropds(dsname);

%IF %SYSFUNC(EXIST(&dsname)) %THEN %DO;

SQL;

PROC

TABLE

&dsname;

DROP

QUIT;

%END;

%IF %SYSFUNC(EXIST(&dsname,VIEW)) %THEN %DO;

PROC

SQL;

VIEW

&dsname;

DROP

QUIT;

%END;

%mend _eg_conditional_dropds;

*libname xxxxxx 'xxx.xxxxxxxx.xxxxxx';

*libname yyyy 'yyyy.yyy.yyyyyyyyyyy';

*libname zzz 'zzzz.zzzzzzz.zzzzzzz';

libname wwwwww 'wwww.wwwwww.wwwwwww';

ods rtf file=’xxxx.xxxx.output’ style = minimal trantab=ascii;

This Top Code will start the Remote submit process on the mainframe, let the mainframe brain know about your needed mainframe SAS libraries, which are local to the Mainframe, and start to capture your ODS output. The “trantab=ascii” code above is crucial, since the default on the mainframe will be EBCDIC. You can also choose to create a PDF file in the same manner:

ods pdf file=’xxxx.xxxx.output’ style=minimal trantab=ascii;

or an EXCEL Spreadsheet:

ODS HTML BODY='xxxx.xxxx.output'(URL='EXLTBL.XLS')

STYLE=MINIMAL

TRANTAB=ASCII;

The Bottom Code for your RSUBMIT sandwich is:

ods rtf close; /*Choose the appropriate one */

ods pdf close; /*Choose the appropriate one */

ods html close; /*Choose the appropriate one */

proc download infile=’xxxx.xxxx.output’

outfile=’k:\xxx\output.rtf’ binary; /* choose one*/

outfile=’k:\xxx\output.pdf’ binary; /* choose one*/

outfile=’k:\xxx\exltbl.xls’ binary; /* choose one*/

run;

endrsubmit;

A FEW COMMENTS

?I am assuming that you have run your SIGNON program that I have described earlier, so you are already logged onto the mainframe.

?The ODS output file is a scratch file. The mainframe will write over the output on the mainframe and then write over the output file on the server every time you run some code. So, when good output is produced,

you must copy the output on the server to a permanent place before you make another run.

?If you are creating EXCEL output, the URL name in the Top Code MUST match the filename in the download.

?You can choose any style you want. I have chosen a fairly plain style.

?The macro in the Top Code is sometimes used by Enterprise Guide? to clean out old datasets from the WORK library before it executes more code. If the macro is not available then the run will stop with an error in the log. It is created every time that Enterprise Guide? starts. But, they are created on your PC, not the mainframe. So, you need to create it in your RSUBMIT code.

?Uncomment the mainframe libraries in the Top Code that will be needed for this project.

TWO POSSIBLE RSUBMIT OPTIONS: RSUBMIT ALL CODE OR SOME CODE TO THE MAINFRAME A number of icons in the Process flow window of an Enterprise Guide? project represent tasks (as opposed to icons that represent output or input). The icons can be generated by either point & click queries, joins, descriptive or analytical statistics. In a given project, you may wish to have ALL of the tasks Rsubmitted to the mainframe, or only a SELECT FEW. This decision will determine where you will place the Top and Bottom code in Enterprise Guide?.

If you wish to submit ALL code in the project to the mainframe whenever you click on an icon: ?Click on tools, options, and then click on “Custom Code” in the left column.

?Check the “Insert custom SAS code before task & query code” box and click on the edit button. Type in the Top Code .

?Check the “Insert custom SAS code after task & query code” box and click on the edit button. Type in the Bottom Code.

?Check the boxes on the left for both the Top & Bottom Code to be active.

?The Top & Bottom Code will be inserted every time you run one of the icons.

?WARNING: After you run each icon that generates RTF, PDF, or EXCEL output, you must copy the output from the scratch file on your server or PC to a permanent file because the output from each icon will

overwrite the output from the previous icon.

?If you want to capture all output from several icons into one document, then right click on each of the given icons and select “Add as Code Template”. Combine all of the code into a code window. Run the code

window. The RSUBMIT sandwich will then be placed above and below all of the code.

?Turn off the RSUBMIT sandwich by checking and unchecking the box to the left of the code edit buttons in Tools/Options. The code is not erased when you uncheck the box, so you do not have to retype it to turn it on again.

?WARNING: The Tools/Options settings for the RSUBMIT sandwich are Enterprise Guide? DEFAULT SETTINGS. They remain defaults, EVEN FOR OTHER PROJECTS! You must remember to turn it off by

unchecking the boxes after you save the project and put a note in your process flow to turn them on after you open the project!

?

If you wish to RSUBMIT only SOME of the icons (other than a Query) in a project to the mainframe: ?Open the icon; click on Preview Code

?Click the insert code button

?Click on the topmost “Insert Code” spot and copy the Top Code into it

?Click on the bottommost spot and copy the Bottom Code into it.

?Edit the download targets on the server to different files so they are not overwritten.

?Uncheck the Tools/Options/”Custom Code” options so they do not run

In this way, only the icons where this code has been inserted will be processed on the mainframe. The other icons will be processed on your PC.

I have discovered that the “Insert Code” feature is not available in the Filter & Query point & click session. This is unfortunate because many filters and queries are CPU and I/O intensive and should be run where the data resides.

To have Enterprise Guide? submit the code for the remote processing on a server or mainframe of point & click

generated queries, you must turn the Tools/Options/”Custom Code” options on before you run the query. It is

annoying, but it works. Assuming you do not want to send everything to the Mainframe, don’t forget to turn the

options off after the query runs.

“BATCH EMAIL” ICON AND TAPES

Sometimes it is necessary to run SAS? in Batch mode, especially when reading or writing data tapes. Even though

you cannot have all of the usual features of Enterprise Guide?, the following ideas allow you to work within it and

maintain all of your code within your PC or server project folders. First, you must create your batch program which

you want to run. The code below starts with standard minimal JCL which is needed for the batch run. It also includes

the code to have SAS? on the mainframe email any output and SAS? Log back to you when it is done. The files that

are used – xxx.xxxxxxx.outpdf and xxx.xxxxxxx.tran are Fixed Block, lrecl=80 scratch files on the mainframe. They

are written over each time this code runs. The first two lines are specific to SSA and need to be customized to your mainframe.

//$xxxxSAS JOB (12340000,T123,,ALK,,OPE-19),xxxxJCH,

// CLASS=T,MSGCLASS=Q,MSGLEVEL=(1,1),REGION=2M,NOTIFY=$xxxx

//S1 EXEC SAS9

//*IN DD DSN=xxxxxx.xxxx.xxxxxxx.xxx.xxxxx,DISP=OLD

//WORK DD SPACE=(6160,(9000,9000),,,ROUND)

/* */

filename outbox email

to='john.c.hennessey@https://www.wendangku.net/doc/3618605699.html,'

Test'

subject='John

attach=(

"xxx.xxxxxxxx.outpdf" type='image/gif' extension='rtf'

"xxx.xxxxxxxx.tran" type='text/plain' extension='txt');

filename outlog xxx.xxxxxxxx.tran';

proc printto log=outlog new; run;

*ods listing close;

filename outpdf xxx.xxxxxxxx.outpdf';

*ods listing close;

*ods pdf file=outpdf style=Styles.printer;

ods rtf file=outpdf style=Styles.printer trantab=ascii;

title 'My Sample Title';

footnote 'My Sample Footnote';

/***************************

*** SAS Code Here ***

**************************/

proc tabulate data=sashelp.class;

class sex age;

table age, sex ;

run;

/****************************

*** End SAS Code Here ***

*****************************/

ods rtf close;

*ods pdf close;

ods listing;

proc printto;run;

data _null_;

file outbox;

put 'John,';

put 'These are my SAS log and output files.';

run;

filename outlog clear;

filename outpdf clear;

“FTP UPLOAD” ICON: SUBMIT A BATCH PROGRAM TO THE MAINFRAME BATCH QUEUE

This code uses FTP to submit your batch program to the mainframe batch queue.

/**********************************************************************

** This is the upload/submit code. I found that the filename path had to

be on one unwrapped line **

** in order to work. I also had to assign and associate the ID and

PASSWORD through the Parameter Manager. **

************************************************************************/

/**************************************************

* Replace with path to the batch program you want to submit **

**************************************************/

filename bprog 'S:\xxxx\xxxxxxxxxx\xxxxxxxxxxxx.sas';

%let SSSS = MainframeSpawnerName;

;

/***********************************************************************

* Make sure that you add the ID and PASSWORD parameters(macro

variables) to this window *

***********************************************************************/

SIGNON SSSS.Spawner USER="&ID" PASSWORD="&PASSWORD";

FILENAME OUTJOB FTP '.X' HOST='xxxx.xxxx.xxx.xxx'

USER="&ID" PASS="&PASSWORD" RCMD='SITE FILE=JES';

DATA _NULL_;

FILE OUTJOB;

INFILE BPROG;

INPUT;

PUT _INFILE_;

RUN;

SIGNOFF;

You will now have an icon in your Process Flow window for the Batch Program itself. And, you will have the icon that submits the batch program to the mainframe batch queue. By clicking on the former, you can edit the batch program and save the edits by closing the batch code window. By, running the latter, you will submit the edited code to the batch queue.

THE “EMAIL ME” ICON

This icon contains the code from the “Batch Email” icon which emails your log and output to you. It does not contain the code which runs the program. If you need to resend your log and output for some reason, this will do it.

rsubmit SSSS.spawner;

filename outbox email

to='xxxxxxx@https://www.wendangku.net/doc/3618605699.html,'

Test'

subject='John

attach=("xxx.xxxxxxxxx.outpdf" type='image/gif' extension='rtf'

"xxx.xxxxxxxx.tran" type='text/plain' extension='txt');

data _null_;

file outbox;

put 'John,';

put 'These are my SAS log and output files.';

run;

endrsubmit;

“MAIN TO SERVER” ICON

This icon is used to download a large dataset from the mainframe to a server without your PC being in the middle of the transfer. It first signs you onto the server. Then, it has THE SERVER sign on to the mainframe and download the dataset. By using a data step to do the download, you can subset the data, create new variables, etc.

SIGNON SSSS.Spawner CONNECTWAIT=NO;

%syslput id=&id;

%syslput password=&password;

RSUBMIT SSSS.Spawner;

OPTIONS COMAMID=TCP;

%LET SSSS= MainframeSpawnerName;

SIGNON SSSS.SPAWNER USER="&ID" PASSWORD="&PASSWORD";

/* Mainframe to server actions */

LIBNAME ABC "E:\xxxxxxxxxx\xxxxx";

LIBNAME ABCM REMOTE 'xxx.xxxxxxxx.xxxxx' SERVER=SSSS.SPAWNER;

DATA ABC.xxxxx(COMPRESS=YES);

ABCM.xxxxx;

SET

RUN;

SIGNOFF SSSS.SPAWNER;

ENDRSUBMIT;

SIGNOFF xxxxxxx;

“DOWNLOAD MAIN PROGRAMS” ICON

After you set up this Utility project, you will want to get all of your Mainframe SAS Programs down from the mainframe and onto your PC or server so that you can maintain them within Enterprise Guide?. This program uses the wildcard feature of PROC DOWNLOAD in a PDS to download ALL of your mainframe programs into a folder on your PC or server.

filename pcdown 'd:\xxxxx';

options comamid=tcp;

%let SSSS= MainframeSpawnerName;

signon remote=SSSS.spawner user='$xxxx' password="&password";

rsubmit;

filename progfile 'xxx.xxxxxx';

proc download infile=progfile('*') outfile=pcdown;

run;

endrsubmit;

signoff;

CONCLUSION

The Enterprise Guide? interface to SAS? provides a powerful tool for power users as well as beginners. The coding capabilities within Enterprise Guide? allow the power user to create many lines of code by clicking the mouse. You can then customize the generated code by inserting additional personal code between the lines of generated code. The structure of the Enterprise Guide? project file allows the creation of a collection of SAS/CONNECTS coding tasks to be conveniently stored on one Process Flow in a project. Each of these tasks can be copied into other Process Flows in the same project, as needed. This project then becomes a powerful tool to make the mainframe behave like a modern computer side by side with your other servers and your PC.

CONTACT INFORMATION

Your comments and questions are valued and encouraged. Contact the author at:

John Hennessey

Office of Research, Evaluation, and Statistics

The Social Security Administration

6401 Security Blvd.

4-C-15 Operations Bldg.

Woodlawn, MD 21235

Work Phone: (410) 965-0102

John.C.Hennessey@https://www.wendangku.net/doc/3618605699.html,

E-Mail:

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.

相关文档