The Little sas book 1.8 Reading the SAS Log Every time you run a Sas job, SAS writes messages in your log. Many SAS programmers ignore the SAS log and go straight to the output. Thats understandable, but dangerous. It is possible-and sooner or later it happens to all of us-to get bogus results that look fine in the output. The only way to know they are bad is to check the SAS log Just because it runs doesn't environment you use, the mode you use(SAS windowing environment, noninteractive, or8 Where to find the Sas log the location of the SAS log varies depending on the operating patch), and local settings. If you submit a program in the windowing environment, you will,by default, see the SAs log in your Log window as in the following figure. Aax If you submit your program in batch r noninteractive mode, the log will aa be written to a file that you can : ronments commands for viewing and printing. The name given to the 营一m you named your SAS program Marathon. sas, then it is a good bet hat your log file will be Marathon. log. At some installations the log and output files are written What the log contains People tend to think of the SAS log as either a rehash of their kilometers and prints the resu * Create a sas data set named distance Convert miles to kilomete i1es=26.22 ilomet 1.61*Mi1 Print the results ROC PRINT dATA distance RUN
16 The Little SAS Book 1.8 Reading the SAS Log Every time you run a SAS job, SAS writes messages in your log. Many SAS programmers ignore the SAS log and go straight to the output. That’s understandable, but dangerous. It is possibleand sooner or later it happens to all of usto get bogus results that look fine in the output. The only way to know they are bad is to check the SAS log. Just because it runs doesn’t mean it’s right. Where to find the SAS log The location of the SAS log varies depending on the operating environment you use, the mode you use (SAS windowing environment, noninteractive, or batch), and local settings. If you submit a program in the windowing environment, you will, by default, see the SAS log in your Log window as in the following figure. If you submit your program in batch or noninteractive mode, the log will be written to a file that you can view or print using your operating environment’s commands for viewing and printing. The name given to the log file is generally some permutation of the name you gave the original program. For example, if you named your SAS program Marathon.sas, then it is a good bet that your log file will be Marathon.log. At some installations the log and output files are written to a single file, so don’t be surprised if you find them together. What the log contains People tend to think of the SAS log as either a rehash of their program or as just a lot of gibberish. OK, we admit, there is some technical trivia in the SAS log, but there is also plenty of important information. Here is a simple program that converts miles to kilometers and prints the result: * Create a SAS data set named distance; * Convert miles to kilometers; DATA distance; Miles = 26.22; Kilometers = 1.61 * Miles; * Print the results; PROC PRINT DATA = distance; RUN;
Chapter 1: Getting Started Using SAs Software 17 If you run this program, SAS will produce a log similar to this otE: sas (2) Proprietary software version 9.00"(TS mo; Licensed to xyz Inc. Site 0098541001 OTE: This session is executing on the XP Pro platform As initialization use cpu time 0.96se 2 1 Create a sas data set named distance Convert miles to kilometers Mi1es=26.22 Kilometers 1.61 Miles 6 Print the results: 3 NOTE: The data set WORK DIStaNce has 1 observations and 2 variables 4 NOTE: DATA statement used(Total 0.03 seconds cpu time 0.03 seconds 27 PROC PRINT DATA distance NOTE: There were 1 observations read from the data set WORK DISTANCE 4 NOTE: PROCEDURE PRINT used (Total process time real time 0.01 seconds cpu time seco The SAS log above is a blow-by-blow account of how SAS executes the program. It starts with notes about the version of SAs and your SAs site number. 2 It contains the original program statements with line numbers added on the left. 3 The DATA step is followed by a note containing the name of the SAS data set created (WORK DISTANCE), and the number of observations(1)and variables(2). a quick glance is enough to assure you that you did not lose any observations or accidentally create a lot o Both DATA and PROC steps produce a note about the computer resources used. At first you probably won't care in the least. But if you run on a multi-user system or have long jobs with large data sets, these statistics may start to pique your interest. If you ever find yourself wondering why your job takes so long to run, a glance at the SAs log will tell you hich steps are the culprits what action it took. You may also find warnings and other types of notes Hmis \s got confused and If there were error messages, they would appear in the log, indicating where SA errors and ot
Chapter 1: Getting Started Using SAS Software 17 If you run this program, SAS will produce a log similar to this: NOTE: Copyright (c) 2003 by SAS Institute Inc., Cary, NC, USA. NOTE: SAS (r) Proprietary Software Version 9.00 (TS M0) Licensed to XYZ Inc., Site 0098541001. NOTE: This session is executing on the XP_PRO platform. NOTE: SAS initialization used: real time 1.40 seconds cpu time 0.96 seconds 1 * Create a SAS data set named distance; 2 * Convert miles to kilometers; 3 DATA distance; 4 Miles = 26.22; 5 Kilometers = 1.61 * Miles; 6 * Print the results; NOTE: The data set WORK.DISTANCE has 1 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 7 PROC PRINT DATA = distance; 8 RUN; NOTE: There were 1 observations read from the data set WORK.DISTANCE NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.00 seconds The SAS log above is a blow-by-blow account of how SAS executes the program. It starts with notes about the version of SAS and your SAS site number. It contains the original program statements with line numbers added on the left. The DATA step is followed by a note containing the name of the SAS data set created (WORK.DISTANCE), and the number of observations (1) and variables (2). A quick glance is enough to assure you that you did not lose any observations or accidentally create a lot of unwanted variables. Both DATA and PROC steps produce a note about the computer resources used. At first you probably won’t care in the least. But if you run on a multi-user system or have long jobs with large data sets, these statistics may start to pique your interest. If you ever find yourself wondering why your job takes so long to run, a glance at the SAS log will tell you which steps are the culprits. If there were error messages, they would appear in the log, indicating where SAS got confused and what action it took. You may also find warnings and other types of notes which sometimes indicate errors and other times just provide useful information.
The Little sas book 1.9 Viewing Your Results in the Output Window How you view or print your output depends on how you submit your program. If you submit your program in the SAS windowing environment, then your output will, by default, go to the Output window. If you choose another way to submit your program, either batch or non-interactive, the your output will probably be in a file on your computer. Use your operating environment's commands to view and print the output file(also called the listing). For example, if you execute your SAS program in non-interactive mode on a UNIX system, then your output will be in a file with an extension Ist. To view the file, you can use either the cat or more commands, and to print the file you would use your system s command for printing files(usually you would type either lp or lpr). The Output window After submitting your program in the SAS windowing environment, operating environments have this turned on by default, while others do not), then you will also o your results will go to the Output window. If you have the SAs Explorer option turned on(som see a listing of the different parts of your output in your Results window. The following figure shows what your Output window might look like after submitting a simple program under Windows Printing or saving the window If you want to print D"sham contents of the Output or save the entire contents of the s Output window, first make the 指,48.21 Output window active by clicking in it, then select either s sav 4ct Print or save As from the file brne pull-down menu. If you are not using a personal computer, then your environment may not be set ser. th up for printing from within SAS If you cannot print from within SAS, then save the output to a file and use your systems 里+wm日的 The Results window When you have a lot of output, the Results window can be very helpful. The Results window is like a table of contents for your output. It lists each procedure that produces output, and if you open, or expand, the procedure in the Results tree, you can see each part of the procedure output. The following figure shows what your screen might look like if you ran the anova (Analysis of Variance) procedure
18 The Little SAS Book 1.9 Viewing Your Results in the Output Window How you view or print your output depends on how you submit your program. If you submit your program in the SAS windowing environment, then your output will, by default, go to the Output window. If you choose another way to submit your program, either batch or non-interactive, then your output will probably be in a file on your computer. Use your operating environment’s commands to view and print the output file (also called the listing). For example, if you execute your SAS program in non-interactive mode on a UNIX system, then your output will be in a file with an extension .lst. To view the file, you can use either the cat or more commands, and to print the file you would use your system’s command for printing files (usually you would type either lp or lpr). The Output window After submitting your program in the SAS windowing environment, your results will go to the Output window. If you have the SAS Explorer option turned on (some operating environments have this turned on by default, while others do not), then you will also see a listing of the different parts of your output in your Results window. The following figure shows what your Output window might look like after submitting a simple program under Windows. Printing or saving the contents of the Output window If you want to print or save the entire contents of the Output window, first make the Output window active by clicking in it, then select either Print or Save As from the File pull-down menu. If you are not using a personal computer, then your environment may not be set up for printing from within SAS. If you cannot print from within SAS, then save the output to a file and use your system’s command for printing files. The Results window When you have a lot of output, the Results window can be very helpful. The Results window is like a table of contents for your output. It lists each procedure that produces output, and if you open, or expand, the procedure in the Results tree, you can see each part of the procedure output. The following figure shows what your screen might look like if you ran the ANOVA (Analysis of Variance) procedure
Chapter 1: Getting Started Using SAs Software 19 There is one entry in the results window for the anova nat in the Outpt window, you see the end of the -atm. procedure s output. If you nf Friar the AnoVa proced n the results tree, by clicking on the plus(+)signs, then you will hoffe Graving see all the different parts of the ANOVA output. Double click on it will appear at the top of the Output window. The following figure shows what your Output window would look like after you double click on the Overall ANovA item in the results Printing or saving parts of the output Using the Results window, it is possible to print or save just the parts of the output you want. First highlight the item you want in the Results window, then bring 3 up the context-sensitive menu In the Windows operating environment you do this with , the right mouse button; in other operating environments, it may be the middle or right mouse button Then select either Print or save As from the pop-up menu. You may also be able to print or save from the File pull-down menu from with. highlight the output part you want. If your SAS environment is not set up for printing in SAS, then save your results to a file and use your operating environments command
Chapter 1: Getting Started Using SAS Software 19 There is one entry in the Results window for the ANOVA procedure. Notice that in the Output window, you see the end of the procedure’s output. If you expand the ANOVA procedure in the results tree, by clicking on the plus (+) signs, then you will see all the different parts of the ANOVA output. Double click on the output you want to see, and it will appear at the top of the Output window. The following figure shows what your Output window would look like after you double click on the Overall ANOVA item in the Results window. Printing or saving parts of the output Using the Results window, it is possible to print or save just the parts of the output you want. First highlight the item you want in the Results window, then bring up the context-sensitive menu. In the Windows operating environment you do this with the right mouse button; in other operating environments, it may be the middle or right mouse button. Then select either Print or Save As from the pop-up menu. You may also be able to print or save from the File pull-down menu once you highlight the output part you want. If your SAS environment is not set up for printing from within SAS, then save your results to a file and use your operating environment’s command for printing files
The Little sas book 1.10 Creating HTML Output If you are using the SAS windowing environment, then you can create output in Hypertext Markup Language(HTML) format with just a few clicks of your mouse The Preferences window To turn on HTML output (in Windows, UNIX, or OpenVMS2 select Options-Preferences from the Tools menu. This opens the Preferences window Click or the Results tab to bring it to the front. Here is what the Results portion of the Preferences window looks like in Windows Genese view I Eat Reat: web I Advancedl V Create listig V Create HTML Falder:[C\DOCUMETWADMIN-I\LOCALS"I\ F V Use wORK folder When you first open this window, you will see a check next to Create Listing. Listing is the default type of output, and it is what you see in the Output window if you are using the Sas windowing environment, or in the output or listing file if you are running in batch mode. You can turn on HTML output by clicking in the box next to Create HTML. To turn off the listing or HTML output, just click to un-check it. In the Preferences window, you can also select a style for hTml output by clicking on the arrow ext to the Style box and scrolling through the list of styles provided with SAS. When you are done with the Preferences window click on the oK button The Results Viewer and Results windows Once you have turned on HTML output, then every time you run a program, your output will automatically appear in the Results Viewer window. The following figure shows what you see after running two simple procedures: MEAN and PRINT. Two windows are showing: the Results Viewer window displaying the HTML output, and the Results window listing all the pieces of output in tree form. ring environment, you can still produce HTML output by using ODS statements(see Guide allows you to create HTML output in a way that is similar to th this section with the added bonus that you can also produce RTF and PDF output. modify your registry settings in order to generate HTML interactively Contact your site's SAS Support Consultant for more information
20 The Little SAS Book 1.10 Creating HTML Output If you are using the SAS windowing environment, then you can create output in Hypertext Markup Language (HTML) format with just a few clicks of your mouse.1 The Preferences window To turn on HTML output (in Windows, UNIX, or OpenVMS2 ), select Options-Preferences from the Tools menu. This opens the Preferences window. Click on the Results tab to bring it to the front. Here is what the Results portion of the Preferences window looks like in Windows: When you first open this window, you will see a check next to Create Listing. Listing is the default type of output, and it is what you see in the Output window if you are using the SAS windowing environment, or in the output or listing file if you are running in batch mode. You can turn on HTML output by clicking in the box next to Create HTML. To turn off the listing or HTML output, just click to un-check it. In the Preferences window, you can also select a style for HTML output by clicking on the arrow next to the Style box and scrolling through the list of styles provided with SAS. When you are done with the Preferences window, click on the OK button. The Results Viewer and Results windows Once you have turned on HTML output, then every time you run a program, your output will automatically appear in the Results Viewer window. The following figure shows what you see after running two simple procedures: MEANS and PRINT. Two windows are showing: the Results Viewer window displaying the HTML output, and the Results window listing all the pieces of output in tree form. 1 If you are not using the SAS windowing environment, you can still produce HTML output by using ODS statements (see chapter 5). In addition, SAS Enterprise Guide allows you to create HTML output in a way that is similar to the one shown in this section with the added bonus that you can also produce RTF and PDF output. 2 If you are using OS/390 or z/OS, you will need to modify your registry settings in order to generate HTML interactively. Contact your site’s SAS Support Consultant for more information