Using the SAS Windowing Environment |
Editor Window |
When you work with SAS programs, you typically use the SAS programming windows (the Editor, Log, and Output windows). Of these programming windows, the Editor is the window that you might use most often. It enables you to do the following:
The Editor Window with Line Numbers Turned On
Note: The Editor window shown here includes line numbers. You might find line numbers helpful when creating or editing programs. To toggle line numbers on or off, issue the NUMBERS command.
There are a number of commands that you might find useful while working on programs in the Editor. You can execute these commands from the command line:
Note: Some of the more useful command line commands have been listed here. Almost all SAS commands are valid in the Editor window. For more information about other command line commands, see Working with SAS Windows.
The left-most portion of the Editor window includes a numbered field. This field is where you enter line commands. These commands are denoted by one or more letters, and can move, copy, delete, justify, or insert lines.
Some common line commands include
When you use some line commands, you also need to specify a location. For example, if you type an M in the numbered field for a line in the Editor, then you must specify where you want the line of text to be moved. You can use the A (after) and B (before) line commands to specify a location.
If you type an A in the numbered field for a line, then the line of text that you want to move will be placed after the line marked with an A after you press the ENTER or RETURN key. If you type a B in the numbered field for a line, then the line of text that you want to move will be placed before the line marked with a B after you press the ENTER or RETURN key.
The following examples show how to use line commands to move a line of text in the Editor window to a new location. To make the following lines alphabetical, place the first line after the last line. To do this, use the M and A line commands:
m 001 Lincoln f Wake Ligon 135 00002 Andrews f Wake Martin 140 00003 Black m Wake Martin 149 a 004 Jones m Wake Ligon 142
After pressing the ENTER or RETURN key, your Editor window lines appear as follows:
00001 Andrews f Wake Martin 140 00002 Black m Wake Martin 149 00003 Jones m Wake Ligon 142 00004 Lincoln f Wake Martin 135
There are many other line commands and combinations of line commands that you can use to edit the statements of a program in the Editor window. For more information, see Working with Text.
Output Window |
You can browse and scroll procedure output from your current SAS session with the Output window. The results of submitting a program, if it contains a PROC step that produces output, are usually displayed in the Output window.
The Output Window Showing the Results of a Submitted Procedure
Most of the command line commands described earlier for the Editor window can be used in the Output window. The CLEAR command is particularly useful in the Output window because all output is appended to the previous output within a SAS session. If you want to avoid accumulating output, then execute the CLEAR command before you submit your next program. From any other window, you can clear the Output window by specifying
clear output
Log Window |
The Log window enables you to:
The Log Window Showing Information about a SAS Session
The Log window shows the SAS statements that you have submitted as well as messages from SAS concerning your program. Under most operating environments, the Log window tells you:
You can use command line commands in the Log window, just as you can in the Editor and Output windows. For more information, see Editor Window.
Using Other Editors |
Although the Editor was designed for writing SAS programs, you can also use the NOTEPAD window to create and edit SAS programs. The NOTEPAD is a text editor that you can use to create, edit, save, and submit SAS programs. You might find NOTEPAD useful as a separate place to work on code. To open NOTEPAD, issue the NOTEPAD or NOTES command.
The SAS NOTEPAD Window with Line Numbers Turned On
Note: The SAS NOTEPAD window shown here includes line numbers. You might find line numbers helpful when you create or edit programs. To toggle line numbers on or off in NOTEPAD, issue the NUMBERS command.
If you open multiple NOTEPADS, then you can cut, copy, and paste text between NOTEPAD windows and the Editor window, multiple SAS sessions, and other applications.
Note: To submit a program from NOTEPAD, you must either select Run Submit or issue the NOTESUBMIT command.
Note: The program information that is presented in this documentation uses the Editor windows as the default editor.
Creating and Submitting a Program |
To create and submit a SAS program:
Type submit on the command line, and then press ENTER or RETURN.
You can also use the function key, menu command, or toolbar item that is assigned to submit programs in your environment.
Note: If you are submitting a program from the SAS NOTEPAD window, then you must use the NOTESUBMIT command instead of the SUBMIT command.
Storing a Program |
On the command line, issue the FILE command followed by a fileref or an actual filename. If you use an actual filename, then enclose it in quotation marks.
The FILE command does not clear the contents of the Editor window. You can store one copy of a program and then continue working in the Editor window.
If you try to store a program with a fileref or filename that already exists, then SAS displays a dialog box. The dialog box enables you to choose to
Often you will want to replace a file with an updated version. To suppress the dialog box, add the REPLACE option to the FILE command after the fileref or complete filename. To add the text in the Editor window to the end of an existing file, specify the APPEND option with the FILE command after the fileref or complete filename.
Note: You can also store a program as a SAS object or as a file that is specific to your operating environment. After you have created or edited a program, select File Save As Object or File Save As, respectively.
Debugging a Program |
You or someone in your organization might be able to help debug a program with the information that appears in the Log window after a program is submitted. If you are having problems with your program, save the contents of the Log window to an external file, if you need to study it after your SAS session has ended.
To save the contents of the Log window to an external file:
From the command line, execute the FILE command followed by a fileref or an actual filename. If you use a filename, then enclose the name in quotation marks.
The FILE command stores a copy of the information in the Log window without removing what is currently displayed. If you specify the name of an existing fileref or file, then a dialog box appears and offers you three choices: overwriting the contents of the existing file with the new file, appending the new file to the existing file, or canceling the command.
Opening a Program |
There is more than one way to open a SAS program. Two of the most popular methods are listed in this section.
To open a SAS program from the Editor window:
To open a SAS program with commands:
On the command line, specify the INCLUDE command followed by an assigned fileref or an actual filename. Remember to enclose an actual filename in single or double quotation marks.
By default, a program is appended to the end of any existing program statements.
Note: If program statements already exist in the Editor, then you can determine where your program is appended by using the B (before) or A (after) line commands. For more information about line commands, see Line Commands.
If you want to replace the text that is already in the Editor window with the program that you open, then specify the REPLACE option with the INCLUDE command after the fileref or filename.
Editing a Program |
Assigning a Program to a File Shortcut |
You can assign a program to a file shortcut to make it easier to find and work with the file in the future. For more information about file shortcuts, see Assigning a File Shortcut.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.