Big Iron 101: Making the Transition from PC to Mainframe without Getting Fired Mary McDonald, PaineWebber, Weehawken, NJ

Abstract Basic Data Processing Knowledge Many new programmers learn SAS in a PC Most of the programmers who write tradi- environment; unfortunately many jobs for tional languages such as Cobol have formal programmers exist in MVS/TSO shops. data processing training. Most SAS pro- This paper’s focus is on how to acquire the grammers, at least in the Northeast, do not. necessary skills and work habits to survive Fortunately most of us have a research back the transition. Topics covered are reference ground, so we do not have to spend a lot of materials, the SAS debugger, good batch time and money acquiring their knowledge programming habits and tricks, being a good and expertise. We can just look it up! One batch citizen, how to get help with error of the nice things about batch processing is messages, and where to find the Display that you will probably have time to do this Manager if you get lonely. while you wait for your jobs to run. The first step should be to acquire some refer- Introduction ence materials. To paraphrase Jean Paul Sartre, the major difference between working on a PC and Essential Reference Materials working on a mainframe is other people. There are four indispensable books: You not only have to the use of the big 1. System 370/390 JCL, Gary DeWard machines with other programmers, but oth- Brown, John Wiley & Sons, Inc. This ers determine its setup and operation. This book makes com- can be very frustrating if you are used to prehensible if not enjoyable. Use it to having complete control over a small ma- look up how to code space, allocate files, chine. The advantage is that the people run- use utility programs, route output, etc. ning the machine are professionals and the hardware and software are much more reli- 2. Tuning SAS Applications in the MVS En- able. The machine is not going to lock up, vironment, Michael A. Raithel, available the hard disk will not die, someone did rou- from SAS Institute. This book explains tine backups, and Bill Gates did not write SAS and how SAS works in the main- the operating system. If anything goes frame environment better than any other wrong, someone else will find it and fix it. source. Read chapters 5, 6, 7, 8, 11, and The other big difference is that there are still especially 12. Skim bits of the rest as more jobs on mainframes and the salaries appropriate. Much of the information in are higher, at least in the New York area. it applies to SAS installation or systems Which is why many PC trained SAS pro- development in SAS. However, the grammers are motivated to make the transi- chapters on compression, indexes, and tion. This does not have to be a difficult or the little tricks for getting big jobs to run unpleasant process. A little common sense are useful for every MVS/SAS pro- and some of the following tricks and tips grammer. should smooth the way. I wrote this paper as a way of organizing some of the sugges- 3. SAS Companion for the MVS Environ- tions that I have passed on to junior pro- ment, Current Edition available from grammers over the years. SAS Institute. Although much of this is available on the web site, other manuals It can happen that you are the only or most or in the ‘Blue Brown Book;’ having skilled programmer in your department. In everything in one volume is handy. this case you will have to look around for yourself. The traditional location for site- 4. Any good MVS TSO or CMS manual as specific documentation is somewhere on the appropriate. computer. You will almost certainly have ISPF – the Interactive System Productivity If you are using files or working with Cobol, Facility – a set of menus and screens de- db2, CICS, Oracle etc. programmers, you signed to help you work. The main menu should invest in a basic text book for that should list ‘News’ and ‘Tutorial’. Try typ- language. It does not have to be good since ing TSO Help on the command line, you you are just going to skim parts of it and should get a list of commands. If you have check for how they do record layouts, file CMS try ‘HELP’, ‘HELP MENU’ or ‘HELP structures and so on. College bookstores HELP’. You may find selections from the tend to have used textbooks that you can IBM manuals and other documentation in pick up at a reasonable price. You probably IBM’s BookManager. At our site it is should be able to read a Cobol record layout mapped to function key 6. QW (from ISPF and correctly code the variable informats in 6 or TSO QW from the command line) at SAS. If you work with db2 tables and do our site gets you to MVS/QuickRef's from not have SAS Access/db2 you will need to Chicago-Soft, which provides reference in- know how to unload tables using a utility formation, including abend codes. If your program such as DSNTIAUL, Platinum or company does not have this, it almost cer- the QMF facility. tainly has something similar. You can even find SAS documentation. However, just be- Many of the things you need to know about cause things are there does not mean that working on the main frame are site specific. they are being maintained. Check the effec- For example: job classes, rules for file tive dates. If the company has an Intranet names, what the retention period for files is, site, also look there for documentation. what the security system will allow you to do, who to call to cancel jobs, how to con- There is a very good chance that interactive trol printing, how to log on to the system. SAS with the Display Manager is available. Hopefully, some of your coworkers know Try typing ‘TSO SAS’ on the command line these tasks and will tell you at least once. or ‘SAS’ from ISPF 6, the Command Shell, They will probably also let you copy JCL or CMS. This should start a SAS session, from working programs. There is a lot to which will be very similar to PC/SAS. know. If you can not get it in writing, put it Some of the function keys will be different, writing yourself and refer back to your but you can remap them. You probably will notes. It is a very, very good idea to develop not be able to mount tapes. It may not sup- the ‘to-do-list’ habit. port the mouse. SAS runs in the foreground so your terminal will be locked up. If you There are variations in how SAS is installed are using terminal emulation on a PC, you and what the default settings are. Run will still be able to use PC software. Proba- PROC OPTIONS, then use the OPTIONS bly the best use of the Display Manager in to statement either in the program or in the JCL debug code or file maintenance. Some to override settings if necessary. companies do not want you to use it much because it interferes with other users. There is some information in the SAS Companion Again, there is a problem is if you want to for the MVS Environment and in Mike test your code against special rare cases. Raithel’s book. You may or may not pick them up. If you have a particularly small sample from a Working Smart large file your chances are limited of getting Good work habits on a PC may or may not the kind of strange data you really need. If be good on a mainframe. Frequently PC you know your data, you can create a better programmers will write a step, submit, de- sample by selecting cases you know are go- bug, submit, etc. If the execution time is 20 ing to be problems. minutes just to mount a tape and read a file, it makes writing the program much too slow Putting a MACRO statement at the begin- if you do it that way. A good rule of thumb ning of the program is a good way to subset, is to do whatever is faster. It is almost al- for example: ways faster to check your code yourself, even if you have to consult a manual, than to %LET SELECT = IF TESTVAR EQ [selection criteria]; let mainframe SAS do it. Most batch pro- grams run against large files and take a long DATA BIG; INFILE BIG; time to run, particularly if you have tapes. INPUT @n TESTVAR @; One way to solve this is to improve execu- &SELECT tion time by running the program in progress INPUT [rest of the file] against test data in a small file that resides ; . . . on DASD. [rest of the program]

There are a number of ways to subset the Reference the macro &SELECT as soon as data; all have advantages and disadvantages. possible in the data step to limit the amount The simplest is to use OBS=. Coding OBS= of work SAS has to do. It is a good idea to 0 on the options statement, which will cause leave the &SELECT in the program, just put SAS to check but not run your code. If you an asterisk in front of the ‘IF’ in the %LET use OBS=n, where n is a reasonably small statement, when the program ‘runs for real’. number, SAS executes your code against the That will make it easier to return to test first n observations in each data set. The dis- mode, when it has to be modified. If you do advantage is that current versions of SAS not know the data and have a lot of imagi- will not allow you to use a WHERE clause nation, simply make up data to create the and OBS=. Ian Whitlock will be presenting test file. a work around for this in Coder's Corner. The major deficiency with this method is If you have the SPOOL Display and Search that the first n observations may not be rep- Facility installed you can watch your pro- resentative of your data. Also if you have gram execute. Look at the test code results several large files, each in a different order, and cancel if necessary. Running the pro- you may not be able to get merges to work. gram in sections mimics the convenience of The OBS= can also be put on each DATA the Display Manager’s keeping work files in STEP or PROC individually, this is a little memory. Write out a dataset, preferably to better, since there is more control. disk at the end of the section. Check it, then do the next logical piece. This has the ad- An alternative is to take a random sample. vantage of not wasting the time to rerun This works best if you have one big file. code that works. Because each program piece is smaller than the whole, it helps would spend printing out a sample of the avoid potential workspace or execution time file. restrictions. A good trick is to wrap a macro around the code you want to comment out, Debugging and of course, not call the macro. There is a SAS DATA Step debugger in some versions of SAS. To use the DATA %MACRO PART1; step debugger, you must start the Applica- tion Server in full-screen mode, and you [large section of program] must be working on the computer where %MEND; SAS software will display the debugger windows. To debug a DATA step, add This allows you to comment out code with /DEBUG to the DATA statement, like this: /* comment */ comments in it. DATA MYLIB.MYDATA/DEBUG; Those of us who learned to program back in the key punch era, which was shortly after When the server executes the program, the the Jurassic, were taught to diagram pro- DATA step debugger windows will pop up grams before we started coding them and to and pause, waiting for you to step through ‘desk check’ all code before submitting it. the code. These are still worthwhile activities. In- denting code, spacing before semicolons, Just because you have a condition code 000 lining up code, skipping lines between sec- does not necessary mean that the program tions, etc. are habits that make it easier to actually worked. Checking code is an art, spot typos. Pay attention to the kind of but there are some techniques you can learn. mistakes you tend to make and look for There was a very nice paper ‘Debugging them when you check your code. 101’ by Peter Knapp last year at NESUG, that provides tips on how to check a pro- Other good habits to develop are coding so gram. It is available on the CD for this that you minimize things that take time and year’s conference. Judicious use of test space, I/O operations, sorting in SAS (use code will save a lot of rewriting and rerun- indexes when ever possible), data steps. ning. PROC MEANS, PROC Always drop unnecessary variables. Use UNIVARIATE and PROC RANK can be PROC DATASETS to delete unneeded used to print out extremes of your data. work datasets. To avoid file merges use PROC FREQ is also helpful to get a sense of formats instead, there are two good papers the distribution of values. on this in Coder’s Corner. PROC APPEND will join two files more efficiently than in an Always check merges of unfamiliar files extra DATA STEP. Remember; the less using the IN= option on the data step: code you write, the less you will get wrong. DATA COMBINED; The editor in TSO/ISPF will browse and MERGE DATA_A(IN=A) search flat files. This allows you to check DATA_B(IN=B); BY [keyvars]; the record layout and the data before you IF A AND B THEN SOURCE=‘AB’; read it. If you have SAS datasets and DM ELSE IF A THEN SOURCE = ‘A ‘; use PROC DATASETS, PROC FSEDIT in ELSE SOURCE = ‘B ’; . . . the Display Manager, to save the time you [rest of data step] RUN; PROC FREQ; TABLE SOURCE; grams, rather than maximize what you are TITLE ‘Test merge DATA_A and DATA_B’; getting from MVS. RUN; Correctly used, SAS’s file compression and Take out some, but not all, test code when the Stored Program Facility can help make the program is finished. Make sure that you your program run better. look at the test code that stays in. Data can suddenly change causing the program to not Getting Along with Others work. Some db2 and Cobol programmers regard SAS programmers as little better than users. Programs can fail for other reasons. MVS A lot of this is jealousy - someone probably Job control language provides a rich source told them that SAS corrects your spelling. of errors. It is important to determine ex- However, it is true that some SAS pro- actly what went wrong. Looking at the JCL grammers are not good batch citizens. SAS portion of the log, particularly the abend has a reputation as a resource hog, partly code, will provide clues. The problem is because SAS programmers do not take the often related to space. The log will tell you time to make their programs more efficient. what the default is. If you need more SAS SAS is also very tolerant, which allows SAS workspace you can ask for more on the exe- programmers to acquire bad habits. cution step: Make a habit of cleaning up after yourself. //SASSTEP EXEC SAS, // WORK=’primary,secondary’ Erase unneeded files, make sure that they are unneeded first. It is very important to There is also a default amount of REGION respect other people’s files. Depending on which is the cpu area in which SAS code how the security system is set up, you may executes. PROCs such as MEANS and be able to erase any test files including those SUMMARY always seem to need more of written by other programmers. this. You can override this as follows: It helps to have friends who know more than //[jobname] JOB CLASS=D,MSGCLASS=Q, you do. The operations staff, those who in- // REGION=[as much as possible], // NOTIFY=[user id] stalled SAS and those who do resource management, are good friends to have. All job classes and user ids are not alike, Many of them use SAS themselves. They some have access to more systems resources tend to be more knowledgeable about MVS, than others. It is worth finding out what TSO, CMS, and systems. than SAS so it can these are at your site and trying to maximize be a mutually beneficial relationship. Try your status. Mike Raithel’s book contains a giving Mike Raithel’s book to whoever in- discussion of coding and using Hiperspaces stalls and maintains SAS. The systems effi- to hold your SAS work library: ciency staff will be pleased if you start a SAS users’ group and help upgrade the other LIBNAME [DDNAME] ‘&TEMPLIB’ HIP; SAS programmers’ skills. Be really nice to the operators. Remember that they can can- This has the advantage of using the main- cel jobs, improve your priority so that you frame’s Expanded Storage resulting in much run faster and answer lots of questions. Try faster I/O. In general, it is best to try to to pickup printouts promptly and avoid acci- minimize the resource needs of your pro- dentally printing really big reports that you don’t want. If it happens, pick it up anyway, tions staff to set up various classes of da- and take it back to your office to throw out. tasets, migrate these to tape, backup, and erase them depending on class. This has SAS has some neat features that can be of taken file management out of the program- use to other programmers, such as its VSAM mers hands, which means that, if you aren’t file management and quick reporting careful, your files vanish. It is vitally im- PROCs. Some of the Cobol trolls may be portant that you understand the procedures willing to use a little SAS if you show them for allocating datasets that will stay around how. There are a lot of ex-Cobol program- as long you need them. This might be mers speaking at NESUG. through coding MGMTCLAS, STORCLAS, EXPDATE, on the DD statement, when files Things that Drive You Crazy and What are pre-allocated, or possibly by sending a to Do About Them memo to the appropriate person. If you have Perfectly good programs that suddenly do RMMISPF – Remote Module Management not run or suddenly take much, much longer Facility you change check tape status. are a hazard of mainframe life. Job per- formance depends on your share of systems Why Otherwise Sane Programmers Love resources, which depends on how many Batch Processing people are sharing the computer, and what The nice thing about working on big main- they are using. This is why increasing the frames is that you do more fun things: workspace, region or space allocated to a thinking about programming, planning sys- file may make things worse. Particularly in tems, learning about SAS, and fewer boring file space allocation, if MVS doesn’t have things such as typing, rebooting the PC, un- the space to give you your primary alloca- jamming the printer, transferring SAS files tion, the job will fail. The counter intuitive to MS Access. You have more time to solution is to reduce the primary allocation. , check your email, get on SAS-L, and of course, write papers for NESUG. There are daily and monthly cycles of pro- duction jobs, back ups, other programmers References and Acknowledgements on the system, and so on. It is a good idea to The best ideas in this paper are from Tuning find out when there is going to be a lot of SAS Applications in the MVS Environment, competition and run your jobs off-peak as Michael A. Raithel, SAS Institute Books by much as possible. This can be done by: Users. submitting in overnight job classes, using a scheduler, or working from home at odd Contact Information hours. It cuts down on the ‘where is it’ calls Mary McDonald from users if you can give them a better time Database Marketing and Analysis Unit estimate. In general, avoid giving a specific PaineWebber Inc. time when people ask when their report will 1200 Harbor Blvd. 6th Floor be ready. Give then a slightly padded range Weehawken, NJ 07087-6791 estimate instead. No one minds if you get [email protected] your work done sooner than they expect.

Possibly the most annoying innovation in recent years is SMS, Storage Management Subsystem. This allows your site’s opera-