Batch vs. Interactive: Why You Need Both Janet E. Stuelpner. ASG. Inc Cary. North Carolina ABSTRACT error was small fa semi-colon was omitted or a closing quotation mark was missing), but caused the program On the mainframe, a great number of people write their to stop running almost immediately. You make the programs and then use batch submission exclusively to minor correction and resubmit the job. Again, the.job is run and test them. As we all know. at times this can waiting on the queue. Do you have any alternatives? be very frustrating. Others use interactive sessions Read on. exclusively. This paper will show the user the reasons why a combination of using batch submissions along WRITING A PROGRAM with an interactive sessions are beneficial to developing new programs. There are many ways to write a program. Everyone has his or her own individual style. Some people write the INTRODUCTION whole program from start to finish before they begin to test and debug it. Others approach a problem modularly. Multitasking on any large mainframe system allows The program is divided into sections. Each section of many users to edit and submit jobs at the same time. the code is written and then tested before moving on to A program is usually written using some type of editor, write the next. When the source code is finished, all and then stored. To run the program. the file is sections have been tested. The modules of the submitted to the operating system. While the job is program can then be run without incurring any errors. executing. the programmer can go on to do other things because execution is completely separate from other operations. SASS) programs consist of many steps which indude data manipulation and the production of output. Programs are usually created in a step by step manner This is terrific if the program runs without error the first where each step builds upon the last. In the course of time. Unfortunately, this rarely happens. More often one program, many SAS data sets may be created. To than not, a program must be run several times before all the bugs are removed and the output is exactly what is save space, many people use the same data set names over and over again, thus writing over old data sets and needed. This can be frustrating during periods of high minimizing the creation of new ones. Others create usage. The program is submitted for execution and it new data sets with every step. This results in a great waits, and waits, and waits. It can be waiting on the number of WORK data sets. The number and method queue to execute because other users' jobs are presently in the system or it can be waiting for of data set creation are a matter of individual choice, but influence how the debugging process will be done. resources that are temporarily unavailable to the job. It takes what seems like forever. In the meantime, the 977
In the following sections, each method of program creation will be discussed with respect to its effect on the debugging process and the advantages and disadvantages of interactive and batch processing. View the list file... can t find the problem yet Revise the program to print out other intermediary files BATCH - THE DISADVANTAGES View the list file... found the problem Batch (or background execution) is defined as a method of running programs in which you prepare a file containing SAS statements and any necessary operating system control statements (e.g., JCl on MVS. DCL on VMS'") and submit the file to the Revise the program View the list file Print the output operating system. When you run jobs in this manner, separate files are created to contain the job log and the listings produced from any output procedu,res. You can You,can see how this can be,a tedious process. Every time a mistake is made or something is overlooked, the view these files on-tine or print them. If you want to program must be revised and rerun. If the system is look at 'any of the intermediary WORK data sets, in a batch submission, you must print the data set in some fashion. A PROC PRINT will cause the data to be very busy, or the program is complicated, this -can mean a great deal of waiting. When you are in the process of writing,a _ program, this can slow things down printed in the list file. Placing PUT statements in a data tremendously. When you have a deadline, there are step (either in a OAT A_NULL _ or within a temporary other ways to proceed in a more timely manner. data step) will cause the data to be printed in the log. BATCH - THE ADVANTAGES The sequence of events in developing a new program can be: Your program is complete. You submit your program to run. You can submit many jobs to run sequentially or Run a program at the same time. At this point it may not matter View the log... errors whether the program waits or runs for 10 minutes or Correct errors half an hour. Once you submit the job. you can do other things because the batch job runs independently View the log... this time there are no errors of anything else. You can even submit the job so that it runs at a later time or overnight when system resources View the list file... the output is not what was are greater becaue.of lower usage. This is a great expected advantag~ when the system is busy and the program Revise the program to print out intermediary must wait_or takes a long time to run. files 978
INTERACTIVE - THE DISADVANTAGES Display Manager requires more resources - primarily memory than a batch job running the same program. An interactive facility is a system that alternately Where real memory or swap space are tight, Display accepts and responds to input. The SAS Display Manager may run slowly. Some mainframe system Manager is such a system. In one session. multiple groups disable it or discourage its use. In many shops tasks can be accomplished. You can write the programs in the Program Editor window, run the program and view the log in the Log window and view they do not make interactive SAS available to the users. INTERACTIVE - THE ADVANTAGES the results in the Output window. The output can be printed from the Output window as well. When a batch job is submitted to the operating system, unless you specifically go through the program and The program is complete. All the errors have been comment out sections, the whole program is run. One removed. You are certain that it will run dean and the output is exactly right. Are you sure you want to run of the advantages of interactive programming is that sections can be run independently of the whole the program in your interactive session? Of course, you program. The INCLUDE and %INCLUDE commands can print the output directly from your session. The make source code available from external files. You problem is that while your job is running. you cannot do anything else. This is only true in MVS systems like TSO and CMS which can handle only one foreground task at a time. In systems like UNIX", OS/2", Windows NT"', etc., you can have several foreground tasks running simultaneously and switch between them at can run your program directly from the external file in your interactive session using %INCLUOE (On an MVS system, using the JCLEXCL option causes SAS to ignore the JCL that is usually included in the source file). You use the INCLUDE command to bring source code from an external file into the Program Editor will. window. Of course, you always have the option of running the whole program. However, if you want to Hopefully, while you were testing your code, you were using a subset of the data that is needed for the final submit portions of the program, this is also possible. Sections of the program can be placed into the project. This will cause the program to run faster. clipboard. Then the code can be submitted to SAS Also, during your testing, you were running a subset of directly from the clipboard. the program. When the first step was completed, you ran the second step. The WORK files were still there, so the program did not have to be run from the beginning. This also saves time. However. now you are ready to run the entire program with all the data As the program is being developed there are several things that can be done. The first is that the program can be saved as it is being written. (Of course, this is not different from writing the program and submitting it from the beginning. This will take time. During this in batch mode.) The program can be run in stages. time, you will not be able to proceed with anything else. Each time a program is run, the intermediary WORK This is the greatest disadvantage of the interactive files are kept. They can be viewed using SAS/FSP system on the mainframe. It is important to note that procedures. If the results are not what you had 979
expected, you can recall the program and run it again after making the appropriate corrections. View the output file Print the output The advantage is that you do not have to run the It seems as if there are the same number of steps as program again just to print out data sets. If the with batch submission. The difference is that with the program was written all at once, you can run the whole thing and look at each data set that is created (provided interactive session, the program is run fewer times and, each iteration of the process takes Jess time because you give each data set a unique name). This makes there is no waiting in batch queues. The reason is that debugging a program a great deal easier. You can see exactly where the error occurred, fix it, and rerun it. Even if the modular approach is taken, errors show up the WORK data sets have not been deleted. They are available for viewing and many more program revisions can take place in a shorter amount of time. immediately and can be fixed and the program rerun. CONCLUSION The sequence of events in developing a new program can be: Run a program View the log... errors Interactive is the better choice while a program is being developed. Throughout the writing and debugging stages of development various segments can be run and tested using a subset of the data. Correct errors Batch is the way to go when a program is complete. Batch processing uses fewer system resources than View the log... this time there are no errors does the display manager. So. when a program has View the list file... the output is not what was expected been debugged and you are ready to produce the final results, run it in batch. View the WORK data sets Revise the program to correct errors View the output... can t find the problem yet When writing a program, the most important factor to consider is comfort. We are all creatures of habit. We tend to do what is easiest, even though it is not necessarily what is most efficient. View the WORK data sets Revise the program to correct errors In the short term, the expense of learning something new is great. However, in the long term, the effort is almost always worthwhile. This holds true in View the output... found the problem programming as well as any other field. In the Revise the program mainframe environment, it is best to use a combination of interactive and batch programming. If the combination is used ccr:ectly. it will save a great 980
amount of time in the process of writing, testing and running programs. ACKNOWLEDGMENTS I would like to gratefully thank two people, without whose help and encouragement this paper would not have been written. The first is my husband, Robert Stuelpner, who suffered through reading and rereading many drafts. The second is Roger Staum, whose helpful hints were much appreciated. SAS is a registered trademark or trademark of SAS Institute, Inc. in the USA and other countries. Other brand product names are registered trademarks or trademarks of their respective companies. 011 indicates USA registration. 981