Using the New Enhanced Editor in SAS 8
The Enhanced Editor is an ASCII editor that uses visual aides that help you program and
debug your SAS programs.
The Enhanced Editor includes many of the features from the Program Editor in addition
to the following:
- SAS program elements can be color coded, including procedures, keywords, informats and
format, dates, numeric and string constants, macro keywords, undefined keywords, and more.
- SCL programs, HTML documents and text document can be color coded.
- You can create your own color schemes or use schemes provided with the Enhanced Editor.
- The Enhanced Editor can automatically indent the next line when you press the Enter key.
- You can view the high level flow of your SAS program or see each detailed statement by
expanding or contracting sections of SAS procedures and data steps.
- Using the Macro recorder, you can create macros that record and play back program
editing commands.
- You can customize keyboard shortcuts for most Enhanced Editor commands.
- Multiple Enhanced Editor sessions can be opened at one time.
The first time you start the SAS System after installation, the Enhanced Editor is
enabled and an empty instance of the Enhanced Editor is opened. You enable or disable the
Enhanced Editor using the Use Enhanced Editor setting in the Preferences dialog box
Edit page.
To enable or disable the Enhanced Editor:
- Select Tools -> Options -> Preferences ->
Edit
- Check the Use Enhanced Editor check box to enable the Enhanced Editor. Uncheck
the Use Enhanced Editor check box to disable the Enhanced Editor.
- Click on OK.
Whenever the Enhanced Editor is enabled, a new instance of the editor is opened, the
status line displays the current cursor position for the new Enhanced Editor window, and
commands are added to the Tools menus as follows:
- Text Editor opens a new instance of the Enhanced Editor.
- Macro provides a submenu for recording, playing, stopping, and editing macros.
- Options provides a submenu for customizing Enhanced Editor options and defining
Enhanced Editor keyboard shortcuts.
When you disable the Enhanced Editor, Enhanced Editor menu commands are not available.
All opened Enhanced Editor windows remain open and you are able to open new Enhanced
Editor windows using the WEDIT command. If the Enhanced Editor is disabled when you start
the SAS System, the Enhanced Editor window will not open.
You can open files in the Enhanced Editor whether or not the Enhanced Editor is enabled
or disabled. When the Enhanced Editor is enabled, you can open files using:
- the Open dialog box
- the WEDIT command in the command bar.
When the Enhanced Editor is disabled, you can open Enhanced Editor files using the
WEDIT command in the command bar or by selecting View -> Enhanced Editor
To stop the Enhanced Editor from opening a new file when the SAS System starts, disable
the Enhanced Editor from the Preferences dialog box Edit page by unchecking the Use
Enhanced Editor check box.
When the Enhanced Editor is enabled, the View menu and the Tools menu
contain commands to open an Enhanced Editor window.
To open an Enhanced Editor window using the View menu, select View ->
Enhanced Editor
To open an Enhanced Editor window using the Tools menu, select Tools ->
Text Editor The Text Editor command in the Tools menu opens an Enhanced
Editor window when the Enhanced Editor is enabled. When it is not enabled, the Text
Editor command opens the SAS NOTEPAD.
- The WEDIT command opens a new Enhanced Editor window. To start the Enhaced Editor from
the command bar, enter one of the following:
WEDIT
- opens a new file in a new Enhanced Editor window.
- WEDIT 'filename'
- opens filename in a new Enhanced Editor window. If the file is not in the current
working folder, then include the path in the filename.
- WEDIT USE
- opens a new file in a new Enhanced Editor window and selects Use Enhanced Editor
in the Preferences dialog box Edit page.
- WEDIT 'filename' USE
- opens filename in a new Enhanced Editor window and selects Use Enhanced Editor
in the Preferences dialog box Edit page.
For more information about the WEDIT command, see WEDIT.
When an Enhanced Editor window is the active window, you can open existing files in the
Enhanced Editor using the Open dialog box. To do this, click the mouse pointer on an
existing Enhanced Editor window bar button and do one of the following to open the Open
dialog box:
- Click on the Open toolbar button
- Enter DLGOPEN from the command bar
- Select File -> Open
- Select File -> Include...
From the Open dialog box, select the file you want to open and then click on OK.
An asterisk ( * ) that appears in the Enhanced Editor window title bar indicates that
the editor contains text that has not been saved to disk. Enhanced Editor windows that
display 'Untitledx' in the title bar are new files that have never been saved.
To save a file to the file in the Enhanced Editor window title bar, do one of the
following:
- Click on the File toolbar button (the diskette)
- Select File -> Save
To save a file for the first time or to save a file with a new name
- Open the Save As dialog box using one of the following:
- Click on the File toolbar button ( the diskette)
- Enter DLGSAVE in the command bar
- Select File -> Save As
- Select a folder in the Save in: field.
- Enter a filename and file extension in the File name: field.
- Click on the Save as type: field and select a file type.
- Click on Save.
You can also define key sequences to save a file to disk in either read-only or write
mode. For more information about using key sequences, see Using
Keyboard Mappings.
ADD INTRO TEXT HERE.
When the Enhanced Editor opens a new file, the title bar of the Enhanced Editor window
contains the Enhanced Editor icon (as shown in Enhanced Editor Icon)
and the text 'Untitledx', where x is a window number.
Enhanced Editor Icon
Once you start entering text, the title bar displays an asterisk ( * ). The asterisk
indicates that there is text in the file that has not been saved to disk. Once you save a
file, the file name displays in the title bar and the asterisk disappears until you start
entering additional text.
On the left side of the Enhanced Editor window is the decoration pane and the code
folding pane. These panes appear as one pane when code folding is enabled. The decoration
pane is used to select lines of text, display line numbers, and create bookmarks. The code
folding pane is used to expand and collapse sections of code.
The Enhanced Editor provides extensive keyboard mappings for
Code folding, when enabled, allows you to expand or collapse one or more sections of
code. A section begins with a section word and ends before the next section word. Section
words include the DATA statement, the PROC statement, and the %MACRO and %MEND statements.
An anchor line is the line in which the section word appears.
To collapse a section, click on -.
To expand a section, click on +.
To enable code folding:
- Select Tools -> Options -> Enhanced Editor...
-> General
- Select Collapsible code sections.
- To display lines separating sections, select Show section lines in text.
- To bracket sections in the code folding pane, select Show section barckets in margin.
- Click on OK.
To disable code folding:
- Select Tools Options Enhanced Editor... General
- Deselect Collapsible code sections.
- Click on OK.
When code folding is disabled, the code folding pane does not display.
For rules on selecting, editing, searching, and replacing text in collapsible sections,
see
When you press the Enter key, you can automatically indent the next line either by the
amount of space the current line is indented or by the amount of space specified for the
Tab size. The latter option is useful as the Enhanced Editor can indent the amount
specified for the Tab size after keywords and section words such as PROC and DO.
To indent by the amount of space the current line is indented:
- Select Tools Options Enhanced Editor
- In the Indentation box, select the Automatic radio button.
To indent after a keyword by the amount of space specified for the Tab key:
- Select Tools Options Enhanced Editor
- Select the type of file you are editing in the File type: field.
- In the Indentation box, select the Smart radio button.
- In the Tabs box, select the number of spaces to indent in the Tab size field.
- If you want to use spaces in the tab space, select the Insert spaces for tabs
check box. If this check box is not selected, blanks are inserted in the tab space.
- Click on OK
If you prefer not to automatically indent, select the None radio button.
Whether you use automatic indenting or not, pressing the Tab key inserts spaces by the
amount of space specified in the Tab size field and moves any text to the right of
the cursor. You can specify whether the tab space is to contain the space character or no
character using the Insert spaces for tabs check box. If this check box is not
selected, blanks are inserted in the tab space.
Note: Changing the tab size will modify tab settings to the new
value in all Enhanced Editor windows.
A macro is a series of Enhanced Editor commands and instructions that you group
together as a single command to accomplish a task automatically. Instead of manually
performing a series of time-consuming, repetitive actions, you can create and run a single
macro. You run a macro from the Tools menu or by using a keyboard shortcut. For
information on defining keyboard shortcut for using macros, see Customizing
the Enhanced Editor Keyboard.
To record a macro:
- Start recording either by pressing Alt + R or by selecting Tools Macro Record
new macro
- Execute the sequence of actions to accomplish the task.
- Stop recording either by pressing Alt + R or by selecting Tools Macro Stop
recording
- If desired, define a keyboard shortcut to play the macro. For information, see Customizing the Enhanced Editor Keyboard
.
An alternative way to create a macro is to add commands using the Create Macro and
Select Commands dialog boxes. To do this:
- Open the Create Macro dialog box by selecting Tools Macro Edit Macros...
- Enter the name of the macro.
- Enter a description of the macro.
- Click on Edit... to open the Select Commands dialog box.
- Select commands from the categories in the Available Commands list box. Click on +
to list the commands for each category. To add a command to the macro, click on
. Repeat this step until all commands are listed in the Macro Contents list box. You can
reorder commands by selecting the command and clicking on ? to move
the command towards the beginning of the macro or to move the command
towards the end of the macro.
- When all commands are in the Macro Contents list box and are ordered correctly,
click on OK.
- In the Create Macro dialog box, click on Add/Update.
To play a macro, use a keyboard shortcut or:
- Open the Play command dialog box by selecting Tools Macro Play Macro
- From the Category list box, select User defined.
- From the Command list box, select the macro .
- Click on Play.
To edit a macro:
- Open the Create macro dialog box by selecting Tools Macro Edit Macros...
- In the Current Macros list box, select the macro.
- Click on Edit to open the Select Commands dialog box.
- To add a command, select a command from the Available Commands list box and click
on .
- To modify a command, first be sure you can modify the command by selecting the command
from the Macro Contents list box. If a command can be modified, the Modify button
becomes active when you select the command in the Macro Contents list box. Click on
Modify to open a dialog box which will enable you to modify the
command.
- To delete a command, select the command in the Macro Contents list box and click
on Delete.
To delete a macro,
- Select Tools Macro Edit Macros...
- Select the macro from the Current Macros list box.
- Click on Delete Macro.
- Click on OK.
This example lists the steps to create an RSUBMIT statement, an ENDRSUBMIT statement, a
blank line between these statements, and tabs in by the amount specified Tabs size:
field in the Enhanced Editor Options dialog box.
- Select View Enhanced Editor
- Select Tools Macro Record New Macro
- In the Enhanced Editor window:
- Press Enter.
- Enter
rsubmit
- Press Enter.
- Enter
endrsubmit;
- Press the up arrow.
- Press the Tab key.
- Select Tools Macro Stop Recording
The resulting macro contains the following commands:
Insert carriage return
Insert character ['r']
Insert character ['s']
Insert character ['u']
Insert character ['b']
Insert character ['m']
Insert character ['i']
Insert character ['t']
Insert character [';']
Insert carriage return
Insert character ['e']
Insert character ['n']
Insert character ['d']
Insert character ['r']
Insert character ['s']
Insert character ['u']
Insert character ['b']
Insert character ['m']
Insert character ['i']
Insert character ['t']
Insert character [';']
Move cursor up
Insert character ['|']
Using key sequences that you define in the Date/Time category of the Enhanced
Editor Keys dialog box, you can add static dates and times to a file. The dates and times
that you can add to a file are listed in Available Dates and Times.
To update dates and time, rekey the appropriate date/time key sequence. For information on
how to define key mappings, see Using Keyboard Mappings.
Available Dates and Times
Date or Time |
Example |
Current 2-digit year |
99 |
Current date and time |
Friday, September 3, 1999 08:28:07 |
Current day of month |
03 |
Current day of week |
Friday |
Current hour in a 12-hour style |
08 |
Current hour in a 24-hour style |
22 |
Meridian indicator |
am |
Current minute |
28 |
Current month index |
09 |
Current month name |
September |
Current second |
07 |
Current year |
1999 |
When you bookmark a line, you create a line marker that is used to easily access that
line.
To bookmark a line, press Ctrl + F2 on an unmarked line.
To unmark a line, press Ctrl + F2 on a bookmarked line.
To go to the next bookmarked line, press the F2 key.
To go to the previous bookmark, press Shift + F2.
A vertical rectangle in the decoration pane indicates that the line is bookmarked. You
can create key sequences for bookmarking commands listed in Bookmarking
Commands. For information on creating and using key sequences, see Customizing the Enhanced Editor Keyboard Using
Keyboard Mappings.
Bookmarking Commands
Go to the next marked line |
Go to the previous marked line |
Mark the current line |
Remove all line markers |
Toggle marker on the current line |
Unmark the current line |
To find text:
- Open the Find dialog box by selecting Edit -> Find...
- Complete the following:
- Find text:
- Enter a text string to find.
- Find in:
- Click in this list box to specify whether to searh in the code only, in the comments
only, or in both the code and comments.
- Direction
- Up specifies to search from the cursor position towards to beginning of the file.
Down specifies to search from the cursor position towards the bottom of the
file.
- Match whole word only
- Select to specify that a match of the text must be a whole word and not a substring of a
word.
- Case sensitive
- Select to specify that upper and lower case characters must match exactly.
- Regular expression search
- Seclec to specify that the text string includes a regular expression. A regular
expression is used to search for a string or substring using special characters as
wildcards. For a description of special characters used in regular expressions, click on Help
in the Find dialog box.
- Click on Find Next.
You can find and replace text by searching the entire file or by selecting a subset of
text and searching only the subset.
To find and replace text
- To search only within a subset of text, select the text.
- Open the Replace dialog box by selecting Edit -> Replace...
- Complete the following:
- Find text:
- Enter a text string to find and replace.
- Replace with:
- enter the replacement string.
- Find in:
- Click in this list box to specify whether to searh in the code only, in the comments
only, or in both the code and comments.
- Direction
- Up specifies to search from the cursor position towards to beginning of the file.
Down specifies to search from the cursor position towards the bottom of the
file.
- Match whole word only
- specifies that any match of the text must be a whole word and not a substring of a word.
- Case sensitive
- specifies that upper and lower case characters must match exactly.
- Regular expressions
- specifies that the text string includes a regular expression. A regular expression is
used to search for a string or substring using special characters as wildcards. For a
description of special characters used in regular expressions, open the Find dialog box
from the Edit menu and click on Help.
- Click on Find Next.
- If the text if found, click on one of the following:
- Replace to replace this single occurance of the text with the
replacement string.
- Replace All to replace all occurances of the text in the file with
the replacement string.
- Replace in Selection to search within the text that you have
selected and replace all occurances of the find string with the replacement string.
Use the key sequences in Key Sequences for Moving the Cursor
to move the cursor within the Enhanced Editor.
To go to a specific line, use the Go To Line dialog box:
- Enter the key sequence Ctrl + G.
- Enter the line number.
- Click on OK.
, use the key sequence Ctrl + G.
For more information about using line numbers, see Using Line
Numbers.
By default, when you click the mouse button past the end of a line, the cursor is
placed after the last character in a line.
To enable the Enhanced Editor for placing the cursor past the end of a line:
- Select Tools -> Options -> Enhanced Editor...
-> General
- Select the Allow cursor movement past end of line check box
- Click on OK.
Key Sequences for Moving the Cursor
Use Key Sequence |
To Move the Cursor.... |
Ctrl + G |
to a specific line number |
Down arrow |
down one line |
Up arrow |
up one line |
Page Down |
down a page |
Page Up |
up a page |
Left arrow |
left one character |
Right arrow |
right one character |
Ctrl + Home |
to the beginning of the document |
Ctrl + End |
to the end of the document |
Home |
to the beginning of the current line |
End |
to the end of the current line |
Ctrl + 0 Ctrl + 9
Ctrl + [
Ctrl + ] |
to the matching parenthesis or bracket |
Alt + right arrow |
to the next case change or word boundary |
Alt + left arrow |
to the previous case change or word boundary |
Ctrl + right arrow |
to the start of the next word |
Ctrl + left arrow |
to the start of the previous word |
Alt + up arrow |
to the first visible line |
Alt + down arrow |
to the last visible line |
Shift + Tab + No Selection |
backwards to the previous tab stop |
Ctrl + up arrow |
towards the top of the file while scrolling up |
Ctrl + down arrow |
towards the bottom of the file while scrolling down |
To move or copy text in your file using drag and drop:
- Select Tools -> Options -> Enhanced Editor... ->
General
- Check the Drag and drop text editing check box and click on OK.
- Select the text to move or copy and hold down the mouse button.
- To move the text, drag the text to the desired location and release the mouse button.
To
copy the text, press the Ctrl key and drag the text to the desired location and release
the mouse button.
Line numbers appear in the decoration pane with the current line color coded in red.
Line numbers can be turned on and off from the Editor Options dialog box.
To turn number on or off:
- Select Tools -> Options -> Enhanced Editor
- Select Show line numbers to turn number on or deselect Show line numbers
to turn numbers off.
- Click on OK.
To submit your program, do one of the following:
- Click on the Run toolbar button.
- Press F3.
- Select Run -> Submit
You can customize how the Enhanced Editor works for you using the Editor Options dialog
box.
To open the Editor Options window from the menu Tools -> Options ->
Enhanced Editor...
Click on the tabs that are located along the top of the dialog box to navigate to the
settings that you want to change, and then select the options you want. When you are
finished, click on OK.
The following sections describe the pages (or tabs) of the Editor Options dialog box
and how to set the formatting options:
The General page lets you specify the general options that control how the Enhanced
Editor works. The following are the General options:
- Home moves cursor to start of text
- specifies whether the Home key places the cursor at the beginning of the text or the
left margin on the current line.
- Virtual spaces
- specifies where the insertion point is positioned when you click the mouse pointer after
the last text character on a line. If Virtual spaces is selected, the insertion
point is positioned where you click the mouse pointer. If Virtual spaces is not
selected, the insertion point is positioned after the last text character on the line.
- Code folding
- specifies whether to enable the expansion and contraction of a DATA step or SAS
procedure. If Code folding is selected, a + in the left gray pane indicates that there are
additional statements to the DATA step or SAS procedure that are not displayed . A - in
the left gray pane indicates that all statements in the DATA step or SAS procedure are
displayed.
- Produce audible alerts for errors
- specifies whether a sound is produced for an invalid operation.
- Show line numbers
- specifies whether to display line numbers in the left gray pane. When line numbers are
displayed, the current line number is red.
- Drag and drop text editing
- specifies whether SAS program files can be dragged and dropped into the Enhanced Editor.
If selected, SAS program files can be dragged and dropped from the Windows Explorer and
from the My Favorites Folder window.
- Word completion
- specifies whether the Enhanced Editor is to recognize unique words after a few character
are entered and pop up a display with a matching word. The user can then press the Tab key
to complete the word. When Display matching prefixes is selected, a pop-up display
shows all potential matching words from which the user can select using the Tab key.
- Auto indent
- specifies whether by pressing the Enter key the next line is automatically indented by
the same amount of space the previous line is indented. If Auto indent is
specified, you can select Use tabs in auto indent to use a tab character in the
indented space. When Use tabs in auto indent is not selected, space characters are
inserted in the indented space.
- Tab size:
- specifies the number of spaces to indent.
The Format options let you specify foregound and background colors, and font styles for
SAS program elements. You can also create and save color schemes. For more information on
using these formatting options, see Setting Formatting Options and
Using Schemes. For a list of default format option settings, see
(new appendix goes here). The following are the Format options:
- File type:
- specifies the type of file whose elements you want to color code. You can color code
file elements for SAS System programs, SCL programs, HTML documents, and text documents.
The default is the file type of the file you are editing at the time you invoke the Editor
Options dialog box.
- Scheme:
- is a name that represents a saved set of file element colors and font for the specified
the file type.
- Name
- specifies the name of the font for the scheme.
- Script
- lists the available language scripts for the specified font.
- File Elements
- lists the elements of the specified file type that can be color coded.
- Foreground:
- lists the colors that can be applied to the text of the specified file element.
- Background:
- lists the colors that can be applied to the background of the specified file element.
- Font Style:
- specifies either Normal, Bold or Italic font style to be applied to
the file element.
- Underlined
- specifies whether the file element is to be underlined.
- Sample:
- displays a sample of the selected file element colors and font.
When you set formatting options, you set them for the elements of the file type
specified in the File type drop-down list. As you make your selections, the Sample
box displays your selected formatting. The formatting options that you specify are applied
to all opened Enhanced Editor sessions of that file type. When you start the SAS System,
the formatting options that are applied to the Enhanced Editor files are the formatting
options that were in effect when the SAS System last ended.
To specify formatting options:
- Open the Editor Options window by selecting Tools -> Options ->
Enhanced Editor...
- Select a file type from the File type: drop-down list. You can format SAS System
programs, SCL program files, HTML documents, and text documents.
- Optionally, you can select a saved formatting scheme from the Scheme: drop-down
list. For more information on using schemes, see Using Schemes.
- From the Font: drop-down list , select a font.
- From the Script: dropt-down list, select a script appropriate for the language
your computer is set up on.
- For each file element you want to format:
- Select a file element.
- Click in the Foreground: color drop-down list and select a color for the file
element. If you want to create a custom color, select Custom and create a color
from the Color dialog box.
- Click in the Background: color drop-down list and select a color for the
background of the file element. If you want to create a custom color, select Custom
and create a color from the Color dialog box.
- From the Font Style: drop-down list, select either Normal, Bold or Italic.
- If you want the element underlined, select the Underlined box.
- Review your selections in the Sample box. When you are done formatting all file
elements, click on OK.
A scheme is a saved set of formatting options. After creating a scheme, you can set
Enhanced Editor formatting options by selecing only a file type and a scheme. Using a
scheme saves you from setting each individual file element.
To create a scheme:
- Select a file type from the File type: drop-down list.
- Select a font and a script.
- For each file element, select a color for the foreground and background, a font style,
and the underlining option.
- Click on Save As... and enter a scheme name in the Save Scheme dialog box.
- Click on OK.
To modify a scheme:
- Select a file type from the File type: drop-down list.
- Select a scheme.
- Make the font and file element changes you want.
- Click on Save As... The selected scheme name ought to be in the Scheme name entry
box.
- Click on OK.
To delete a scheme:
- Select a file type.
- Select the scheme you want to delete.
- Click on the Delete button.
MAIN
Last updated: 01/18/06 by Karl Ho