Chapter 1: Getting Started Using SAs Software 11 to or cannot use a windowing environment. Noninteractive mode is usually started by typing SAS at your system prompt(shown here as $), followed by the filename containing your program statements: s SAs MyFile. sas Batch or background mode With batch or background mode SAS program is in a file. You submit the file for processing with SAS r Run that Sas job Your SAS program may start executing immediately, or it could be put a queue behind other jobs. Batch processing is used a lot on mainframe omputers, which are capable of executing many processes at one time. You can continue to work on your computer while your job is being processed, or better yet, you can go to the baseball game and let the computer work in your absence. Batch processing is usually less expensive than other methods and is especially good for large jobs which can be set up to execute at off hours when the rates are at their lowest. When your job is complete, the results will be placed in a file or files, which you can display or print at any time. Batch processing may not be available for your operating environment. Check the SAS Help and Documentation for your operating environment to see if it is available, then check with your SAs Support Consultant to find out how to submit SAS programs for batch processing. Even sites with he same operating environment may have different ways of submitting jobs in batch mode Remote submit If you have SAS/CONNECT software, it is possible to write and develop your SAS programs on one system, then submit them for processing on another. Using this method, you write your program on your local machine, establish a connection to the remote machine and run the program on the remote machine. Then the results are delivered back to your local machine. You might want to do this if your remote machine is much more powerful than your local machine, and you are running very large programs. Also, you might need to access large or shared data files on the remote machine. Check with your SAS Support Consultant to find out if this is an option at your Interactive line mode This mode is mentioned only because you might see it in the SAS documentation, and you might get into it by accident. In interactive line mode, you are prompted for SAS statement one line at a time. There is no easy way to correct mistakes once you have entered them, so unless you are an excellent typist, and an excellent programmer, interactive line mode is exceedingly frustrating If you do find yourself in this mode (you will know when you get a 1? as a prompt), you can get out by typing ENDSAS; and pressing ENTER. For example Seek assistance from your SAS Support Consultant to find out why you got into line mode and how to avoid it in the future
Chapter 1: Getting Started Using SAS Software 11 to or cannot use a windowing environment. Noninteractive mode is usually started by typing SAS at your system prompt (shown here as $), followed by the filename containing your program statements: $ SAS MyFile.sas Batch or background mode With batch or background mode, your SAS program is in a file. You submit the file for processing with SAS. Your SAS program may start executing immediately, or it could be put in a queue behind other jobs. Batch processing is used a lot on mainframe computers, which are capable of executing many processes at one time. You can continue to work on your computer while your job is being processed, or better yet, you can go to the baseball game and let the computer work in your absence. Batch processing is usually less expensive than other methods and is especially good for large jobs which can be set up to execute at off hours when the rates are at their lowest. When your job is complete, the results will be placed in a file or files, which you can display or print at any time. Batch processing may not be available for your operating environment. Check the SAS Help and Documentation for your operating environment to see if it is available, then check with your SAS Support Consultant to find out how to submit SAS programs for batch processing. Even sites with the same operating environment may have different ways of submitting jobs in batch mode. Remote submit If you have SAS/CONNECT software, it is possible to write and develop your SAS programs on one system, then submit them for processing on another. Using this method, you write your program on your local machine, establish a connection to the remote machine, and run the program on the remote machine. Then the results are delivered back to your local machine. You might want to do this if your remote machine is much more powerful than your local machine, and you are running very large programs. Also, you might need to access large or shared data files on the remote machine. Check with your SAS Support Consultant to find out if this is an option at your site. Interactive line mode This mode is mentioned only because you might see it in the SAS documentation, and you might get into it by accident. In interactive line mode, you are prompted for SAS statements one line at a time. There is no easy way to correct mistakes once you have entered them, so unless you are an excellent typist, and an excellent programmer, interactive line mode is exceedingly frustrating. If you do find yourself in this mode (you will know when you get a 1? as a prompt), you can get out by typing ENDSAS; and pressing ENTER. For example 1? ENDSAS; Seek assistance from your SAS Support Consultant to find out why you got into line mode and how to avoid it in the future
The Little sas book 1.6 Windows and Commands in the SAs Windowing Environment It used to be that SAs looked pretty much the same on all platforms, and you couldn t change its appearance. But now SAS adopts the look and feel of your operating environment, and there are many ways in which you can customize your SAS environment. This is good for you because many aspects of the SAS windowing environment will be familiar, and if you don' t like the default view, you can change it. It makes writing about it more difficult, because we can t tell you exactly what your SAS session will look like and how it will behave. However, there are many common elements between the various operating environments, and you will probably already be familiar with those elements which are different. The Sas Windows There are five basic SAS windows: the Results and Explorer windows, and three programming windows: Editor, Log, and Output. It is possible to bring up SAS without all these windows, and sometimes the windows are not immediately visible( for example, in the windows operating environment, the Output window comes up behind the Editor and Log windows), but all these windows do exist in your SAS session. There are also many other SAS windows that you may use for tasks such as getting help, changing SAS system options, and customizing your SAS session. The following figure shows the default view for a Microsoft Windows SAS session, with pointers to the five main SAS windows TSAS Fle Edt Wew Tools Run 5oaiors Widow Help 引D日舀静×⊙ of SAS Envn 目 og Output (under the AEditor-UntitledI ditor and Log Results Editor under the一回Pem小o日区 Explorer Editor This window is a text editor. You can use it to type in, edit, and submit SAS programs as well as edit other text files such as raw data files. In Windows operating environments, the default editor is the Enhanced Editor. The Enhanced Editor is syntax sensitive and color codes your programs making it easier to read and find mistakes. The Enhanced Editor also allows you to collapse and expand the various steps in your program. For other operating environments, the default editor is the Program Editor whose features vary with the version of SAS and operating environment
12 The Little SAS Book Results (under the Explorer window) 1.6 Windows and Commands in the SAS Windowing Environment It used to be that SAS looked pretty much the same on all platforms, and you couldn’t change its appearance. But now SAS adopts the look and feel of your operating environment, and there are many ways in which you can customize your SAS environment. This is good for you because many aspects of the SAS windowing environment will be familiar, and if you don’t like the default view, you can change it. It makes writing about it more difficult, because we can’t tell you exactly what your SAS session will look like and how it will behave. However, there are many common elements between the various operating environments, and you will probably already be familiar with those elements which are different. The SAS Windows There are five basic SAS windows: the Results and Explorer windows, and three programming windows: Editor, Log, and Output. It is possible to bring up SAS without all these windows, and sometimes the windows are not immediately visible (for example, in the Windows operating environment, the Output window comes up behind the Editor and Log windows), but all these windows do exist in your SAS session. There are also many other SAS windows that you may use for tasks such as getting help, changing SAS system options, and customizing your SAS session. The following figure shows the default view for a Microsoft Windows SAS session, with pointers to the five main SAS windows. Editor This window is a text editor. You can use it to type in, edit, and submit SAS programs as well as edit other text files such as raw data files. In Windows operating environments, the default editor is the Enhanced Editor. The Enhanced Editor is syntax sensitive and color codes your programs making it easier to read and find mistakes. The Enhanced Editor also allows you to collapse and expand the various steps in your program. For other operating environments, the default editor is the Program Editor whose features vary with the version of SAS and operating environment. Explorer Log Output (under the Editor and Log windows) Editor
Chapter 1: Getting Started Using SAs Software 13 Log The Log window contains notes about your SAS session, and after you submit a SAS program, ly notes, errors, or warnings associated with your program as well as the program statements hemselves will appear in the Log window Output If your program generates any printable results, then they will appear in the Output windo Results The Results window is like a table of contents for your Output window; the results tree lists each part of your results in an outline form Explorer The Explorer window gives you easy access to your SAS files and libraries The sas commands There are SAS commands for performing a variety of tasks. Some tasks are probably familiar, such as opening and saving files, cutting and pasting text, and accessing Help. Other commands are specific to the SAS System, such as submitting a SAS program, or starting up a SAS application You may have up to three ways to issue commands: menus, the toolbar, or the SAS command bar (or command line). The following figure shows the location of these three methods of issuing SAs commands in the Windows operating environment default view File Edit View Tools Solutions Window Help Pull-down menus Toolbar Menus Most operating environments will have pull-down menus located either at the top of each window, or at the top of your screen. If your menus are at the top of your screen, then the menus will change when you activate the different windows(usually by clicking on them).You may also have, for each window, context-sensitive pop-up menus that appear when you press the right or center button of your mouse. Toolbar The toolbar, if you have one gives you quick access to commands that are already ccessible through the pull-down menus. Not all operating environments have a toolbar SAS command bar The command bar is a place that you can type in SAS commands. In some operating environments the command bar is located with the toolbar (as shown here); in other operating environments you may have a command line with each of the SAS windows(usually indicated by Command=>). Most of the commands that you can type in the command bar are also ough the pull-down the toolbar Controlling your windows The Window pull-down menu gives you choices on how the windows are placed on your screen. You can also activate any of the programming windows electing it from the window pull-down menu, typing the name of the window in the command line area of your SAS session, or simply clicking on the window
Chapter 1: Getting Started Using SAS Software 13 Log The Log window contains notes about your SAS session, and after you submit a SAS program, any notes, errors, or warnings associated with your program as well as the program statements themselves will appear in the Log window. Output If your program generates any printable results, then they will appear in the Output window. Results The Results window is like a table of contents for your Output window; the results tree lists each part of your results in an outline form. Explorer The Explorer window gives you easy access to your SAS files and libraries. The SAS Commands There are SAS commands for performing a variety of tasks. Some tasks are probably familiar, such as opening and saving files, cutting and pasting text, and accessing Help. Other commands are specific to the SAS System, such as submitting a SAS program, or starting up a SAS application. You may have up to three ways to issue commands: menus, the toolbar, or the SAS command bar (or command line). The following figure shows the location of these three methods of issuing SAS commands in the Windows operating environment default view. Menus Most operating environments will have pull-down menus located either at the top of each window, or at the top of your screen. If your menus are at the top of your screen, then the menus will change when you activate the different windows (usually by clicking on them). You may also have, for each window, context-sensitive pop-up menus that appear when you press the right or center button of your mouse. Toolbar The toolbar, if you have one, gives you quick access to commands that are already accessible through the pull-down menus. Not all operating environments have a toolbar. SAS command bar The command bar is a place that you can type in SAS commands. In some operating environments the command bar is located with the toolbar (as shown here); in other operating environments you may have a command line with each of the SAS windows (usually indicated by Command=>). Most of the commands that you can type in the command bar are also accessible through the pull-down menus or the toolbar. Controlling your windows The Window pull-down menu gives you choices on how the windows are placed on your screen. You can also activate any of the programming windows by selecting it from the Window pull-down menu, typing the name of the window in the command line area of your SAS session, or simply clicking on the window. SAS Command Bar Pull-down Menus Toolbar
The Little sas book 1.7 Submitting a Program in the SAS Windowing Environment Naturally after going to the trouble of writing SAS programs, you want to see some results. As we have already discussed, there are several ways of submitting SAS programs. If you use the SAS windowing environment, then you can edit and submit programs, and see results all withi he windowing environment Getting your program into the editor The first thing you need to do is get your nd for opening files should be familiar. SAS tries to follow conventions that are common o. a program into the Editor window. You can either type your program into the editor, or you can ram into the Editor window from a file. The commands for editing in the editor your operating environment. For example, to open a file in the editor, you can select Open from the File pull-down menu. For some operating environments you may have an Open icon on the toolbar, and you may also have the option of pasting your file into the editor from the clipboard Submitting your program Once your program appears in the editor, you execute it using hw to exec te mhe auB ep enming on your operating environment you have a few choices on Use the Submit icon on the toolbar 下sAs Make the Editor window active and enter SUBMIT in the le Ed wew Toos Run Solutions window Hep command line area of your SAS session. √ Sumt 口日‖ Make the editor window active and select submit d yiew loot Solutiont Wondow Heb from the Run pull-down menu. enl dSAS En 目百如 Libraries Fde sI Signon Remote Subnit. The figure to the right shows a program in the Enhanced Editor in the Windows operating environment ready to be submitted using th Submit icon on the toolbar
14 The Little SAS Book 1.7 Submitting a Program in the SAS Windowing Environment Naturally after going to the trouble of writing SAS programs, you want to see some results. As we have already discussed, there are several ways of submitting SAS programs. If you use the SAS windowing environment, then you can edit and submit programs, and see results all within the windowing environment. Getting your program into the editor The first thing you need to do is get your program into the Editor window. You can either type your program into the editor, or you can bring the program into the Editor window from a file. The commands for editing in the editor and for opening files should be familiar. SAS tries to follow conventions that are common for your operating environment. For example, to open a file in the editor, you can select Open from the File pull-down menu. For some operating environments you may have an Open icon on the toolbar, and you may also have the option of pasting your file into the editor from the clipboard. Submitting your program Once your program appears in the editor, you execute it using the SUBMIT command. Depending on your operating environment, you have a few choices on how to execute the SUBMIT command. Use the Submit icon on the toolbar. Make the Editor window active and enter SUBMIT in the command line area of your SAS session. Make the Editor window active and select Submit from the Run pull-down menu. The figure to the right shows a program in the Enhanced Editor in the Windows operating environment ready to be submitted using the Submit icon on the toolbar
Chapter 1: Getting Started Using SAs Software 15 Viewing the SAS Log and Output If you are using the Enhanced Editor(Windows operating environment), after you submit your program, the program remains in the Enhanced Editor window and the results of your program go into the Log and Output windows. If you are sing the Program Editor(all other operating environments) then your results also go into the Log and Output windows, but your program disappears from the Program Editor window. At first it may be a shock for you to see your program disappear in front of your eyes. Don' t worry: the program you spent so long writing is not gone forever. If your roduced any output, then you will also get new entries in the Results window. The Results window is like a table of contents for your SAS output and is discussed in more detail in section 1.9. This figure is an example of what your screen might look like after you submit a program from the Enhanced Editor x You may not see all three of the programming windows(Editor, Log, and Output)at the same Melon Ki lantern time. In some operating 22 environments the windows are placed one on top of the other. You can bring a window to the top by clicking on it, typing its name in the command line area, or electing it from the window Getting your program back Unfortunately for most of us, our programs do not run perfectly every time. If you have an error in your program, you will most likely want to edit the program and run it again. If you are using the Program Editor window, you will need to get your program back in the Program Editor window using the RECALL command You have two choices for executing the RECALL command. TSAS File Edt Mew Toos Run Salutions window Hep Make the Program Editor the active window,then enter RECALL in the command line area of your SAS session. Edr wew Tools Run Solutions window Heb Make the Program Editor the active window, then select Recall Last Submit from the Run pull-down menu Re康s 团词Prnt: The SA5 Subent N Lines. The rECall command will bring back the last block of statements you submitted. If you use the RECALL Remoe submit command again, it will insert the block of statements RemgteGet. submitted before the last one, and and so on, until it Remote Dsplay retrieves all the statements you submitted
Chapter 1: Getting Started Using SAS Software 15 Viewing the SAS Log and Output If you are using the Enhanced Editor (Windows operating environment), after you submit your program, the program remains in the Enhanced Editor window and the results of your program go into the Log and Output windows. If you are using the Program Editor (all other operating environments) then your results also go into the Log and Output windows, but your program disappears from the Program Editor window. At first it may be a shock for you to see your program disappear in front of your eyes. Don’t worry; the program you spent so long writing is not gone forever. If your program produced any output, then you will also get new entries in the Results window. The Results window is like a table of contents for your SAS output and is discussed in more detail in section 1.9. This figure is an example of what your screen might look like after you submit a program from the Enhanced Editor. You may not see all three of the programming windows (Editor, Log, and Output) at the same time. In some operating environments, the windows are placed one on top of the other. You can bring a window to the top by clicking on it, typing its name in the command line area, or selecting it from the Window menu. Getting your program back Unfortunately for most of us, our programs do not run perfectly every time. If you have an error in your program, you will most likely want to edit the program and run it again. If you are using the Program Editor window, you will need to get your program back in the Program Editor window using the RECALL command. You have two choices for executing the RECALL command. Make the Program Editor the active window, then enter RECALL in the command line area of your SAS session. Make the Program Editor the active window, then select Recall Last Submit from the Run pull-down menu. The RECALL command will bring back the last block of statements you submitted. If you use the RECALL command again, it will insert the block of statements submitted before the last one, and so on and so on, until it retrieves all the statements you submitted