Get some SAS tools
Contents Index Conventions First Page Web Site
Next Section Previous Section

Running and Debugging

Executing a SAS Program

You can run your SAS program (sans JCL of course) from within Multi-Edit. Press F3, use the "running man" button on the SAS toolbar, or select SAS-Run SAS from the context sensitive menu. Your program runs hidden in the background and the results (log and output) display in new edit windows when it completes. It seems that you can get a better response time from SAS if it is left up and running (minimized or hidden behind Multi-Edit).

If your SAS program will run for quite a while, and you want to continue editing you can use context menu item SAS-Run SAS BG. This will cause SAS to truly run in the background. The down side, you must open the log and or output files manually when SAS completes.

Before you run SAS for the first time you will need to point EZRTools;) at the location of SAS. This can be accomplished by selecting SAS-Change SAS Directory from the context sensitive menu. If you have a new installation you will be prompted to provide the path the first time you try to run SAS. You can use Change SAS Directory to hop between different release levels if you have multiple installations.

Find Selected Item

Three macros are available to find an item that you have selected. Two of the macros move your cursor to the next or last occurrence of the selected text. The third finds all occurrences and lists them in the Search List (bottom of edit screen). These macros are executed from the context sensitive menu or through key combinations.

Find All (Global)

Select Find Selected Text -Find All , press SAS toolbar button "Magnify Glass + Document" , or press Cntl-Shft-m to find all occurrences of the currently selected string. The menu selection is located under the Tools menu item of the SAS context sensitive menu. Find Selected Text is located on the primary context sensitive menu while in LOG files. After you invoke the macro all occurrences of the string in the current file are listed in the Search List. You can hop to that line by double clicking it in the Search List.

Find Forward (Next)

Select Find Selected Text -Find Forward , press SAS toolbar button "Magnify Glass + Right arrow" or press Cntl-Shft-n to find the next occurrence of the currently selected string. The menu selection is located under the Tools menu item of the SAS context sensitive menu. Find Selected Text is located on the primary context sensitive menu while in LOG files. After you invoke the macro the cursor is moved to the next occurrence of the selected string. The string is highlighted, allowing you to invoke the macro again, or replace the text.

Find Backward (Last)

Select Find Selected Text -Find Backward , press SAS toolbar button "Magnify Glass + Left arrow" or press Cntl-Shft-b to find the prior occurrence of the currently selected string. The menu selection is located under the Tools menu item of the SAS context sensitive menu. Find Selected Text is located on the primary context sensitive menu while in LOG files. After you invoke the macro the cursor is moved to the previous occurrence of the selected string. The string is highlighted, allowing you to invoke the macro again, or replace the text.

Viewing the Log and output

Log and Output file names

The log and output file names are created by combining the path and filename of the source code file and replaces the SAS extension with log or out. Both the log and output file are overwritten upon subsequent runs of the same program. If you need to compare logs from multiple runs use the log backup tool.

Subsetting the Log

When you view the log, your context sensitive menu changes. It now has entries to Show Only certain types of lines from the log. This selection displays a sub-menu with entries that indicate what type of lines are not hidden. The descriptions of what is not hidden are listed below. These functions are also accessed through the LOG toolbar. The toolbar buttons have Shortened versions of the menu item names. Turn Off is the Clear button, Unintended Conversions is the Conv button.

Errors Show only ERROR messages.
Warnings Show only WARNING messages.
Notes Show only (and all) NOTE messages.
Source Lines Shows only the lines of source code, e.g.. Proceeded with a line number.
Observations Shows only note messages indicating the number of observations processed.
Zero Obs. Shows only note messages indicating that zero observations were processed.
Unintended Conversions Shows only note messages indicating numeric to character conversions or visa-versa
Missing Values Shows only note messages indicating that there were missing values.
Macro Messages Shows only the lines that are macro related output.
Debug Shows only lines with the word "Debug" as the first word, and the next line below it.
Clear Turns off show only so that all log file lines are listed.
on/off Toggles the hiding of lines on and off.
Block Hides a selected block of lines.

Using a Subset Log

Now that you have reduced the lines shown in the log to some subset of the whole log, what can you do? Notice there are small buttons with a plus sign on the far left of the lines that are visible. You can click on a button and the hidden lines below the button are shown down to the next non-hidden line. At this point the button changes to a minus sign. Clicking this button will re-hides the exposed lines.

The context sensitive menu has an selection to Toggle Show Only off and on. This can also be accomplished from the On Off button on the LOG toolbar. When you use this option your cursor remains on the line that it was on (and so does your view). But all the hidden lines are shown. This does not alter the position of the line in the edit window.

Synchronizing Source and Log

While viewing the log, you can put your cursor on any source code line and jump to that line in the code file. If the file is not open in an edit window then it opens. This function only works with source code lines in the log file that also exist in the source code file. For example source located in files %included or autocalled macros would not be found. For best results use list options SOURCE, SOURCE2, MACROGEN If you are executing programs on a remote host, you will need to download the source and log files. They should be named with same major name and extensions of .sas and .log. For example myfile.sas and myfile.log. They should also be located in the same directory. You invoke this function by selecting Hop to Source Line in the LOG context menu, or press the Go To button on the LOG toolbar.

Backing up the Log File

If you want to use to extensive file compare facilities against logs from two runs of the same program you need to back up your log. The context sensitive menu for log extensions has an item called Backup this Log. This is also located on the SAS context sensitive menu under Tools-Backup Log file. You can also press the Dup Log button on the SAS or LOG tool bars. Selecting this action will create a copy of the log in a sub directory called "backlog" located in the directory containing the log file.

Removing Output Files

The context sensitive menu for SAS files has an entry on the menu to do cleanup log and out files. The entry is under the Tools menu called Delete Log, Output files. You can also press the Clean Up button on the SAS toolbar. Selecting this option will delete all log, backed up log and output files associated with the source file. You are not prompted to confirm.

Extracting a Table from Output Files

If you need to extract the table data from the output of Procs you can use this tool to do this. Here is an example of Proc Logistics output:

Analysis of Maximum Likelihood Estimates
Parameter seeover DF Estimate Standard
Error
Wald
Chi-Square
Pr > ChiSq
Intercept 2 1 -1.8836 0.1623 134.7254 <.0001
Intercept 1 1 -1.8566 0.1223 111.7884 <.0001
Followed by more rows

Now to extract this data, for use in a presintation, word doc, whatever, It would be a simple cut and paste, except for... page breaks, repeating headers and SAS time stamps. The table extractor tool makes this job easy. All you need to do is select the table title, in the example above that would be "Analysis of Maximum Likelihood Estimates", with your mouse, and invoke to macro.

How to invoke the macro

You can do this a few different ways. The simplest is use menu item Macro-Run and type sas^tablecut and press Ok. You can also assign it to a control key or a menu item. Note to assign the macro to your sas or log context menus, you will have to add the extension to the extension list for one of those extensions.

To assign to the Context menu

To add the extension to either SAS or LOG extensions select Tools-Customize-Extensions Select SAS or LOG and press edit. Then add out to the list of extensions in the upper right hand corner. Now to add the tool to the contect menu select Tools-Customize-Menus. Select SAS or LOG and press Edit. Select the menu item you want the new entry to be above. Then press Insert. Fill in the menu items text, then click the button next to Command. Then search for "Table Capture", it will be in the EZRTools section. Select this command. Say Ok and your done.

To assign it to a key combination

Go to Tools-Customize, set the left side to "General" (at the top) Click on the "Keys/Commands..." button. Then search for "Table Capture", it will be in the EZRTools section. Click on Edit and use the Primary Key area to assign a key combination.

Next Section Previous Section

Copyright © 2000- , Martin Works Inc., Text, graphics, and HTML code are protected by US and International Copyright Laws, and may not be copied, reprinted, published, translated, hosted, or otherwise distributed by any means without explicit permission. SAS® is a registered trademark of SAS Institute, Inc. in Cary, NC. Multi-Edit® is a trademark of Multi-Edit Software Inc. All other logos and trademarks in this site are property of their respective owners.