rssunt.gif (12308 bytes)


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.

 


Enhanced Editor Features

The Enhanced Editor includes many of the features from the Program Editor in addition to the following:

 


Enabling and Disabling the Enhanced Editor

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:

  1. Select Tools  -> Options -> Preferences -> Edit
  2. Check the Use Enhanced Editor check box to enable the Enhanced Editor. Uncheck the Use Enhanced Editor check box to disable the Enhanced Editor.
  3. 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:

 

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.

 


Opening Files

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:

 

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.

Using Menus to Open an Enhanced Editor Window

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.

Using the Command Bar to Open Files

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.

Opening an Existing File

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:

 

From the Open dialog box, select the file you want to open and then click on OK.

 


Saving Files

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:

 

To save a file for the first time or to save a file with a new name

  1. Open the Save As dialog box using one of the following:
  2. Select a folder in the Save in: field.
  3. Enter a filename and file extension in the File name: field.
  4. Click on the Save as type: field and select a file type.
  5. 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.

 


Checking for Errors

 


Using the Enhanced Editor Window

ADD INTRO TEXT HERE.


Overview of the Enhanced Editor Window

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

[IMAGE]

 

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.

Using Keyboard Mappings

The Enhanced Editor provides extensive keyboard mappings for

Using Code Folding

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:

  1. Select Tools  -> Options -> Enhanced Editor...  -> General
  2. Select Collapsible code sections.
  3. To display lines separating sections, select Show section lines in text.
  4. To bracket sections in the code folding pane, select Show section barckets in margin.
  5. Click on OK.

To disable code folding:

  1. Select Tools  [arrow] Options [arrow] Enhanced Editor... [arrow] General
  2. Deselect Collapsible code sections.
  3. 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

 


Using Automatic Indenting and Tabs

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:

  1. Select Tools  [arrow] Options [arrow] Enhanced Editor
  2. In the Indentation box, select the Automatic radio button.

To indent after a keyword by the amount of space specified for the Tab key:

  1. Select Tools  [arrow] Options [arrow] Enhanced Editor
  2. Select the type of file you are editing in the File type: field.
  3. In the Indentation box, select the Smart radio button.
  4. In the Tabs box, select the number of spaces to indent in the Tab size field.
  5. 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.
  6. 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.   [cautend]

Using Abbreviations


Using Macros

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:

  1. Start recording either by pressing Alt + R or by selecting Tools  [arrow] Macro [arrow] Record new macro
  2. Execute the sequence of actions to accomplish the task.
  3. Stop recording either by pressing Alt + R or by selecting Tools  [arrow] Macro [arrow]  Stop recording
  4. 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:

  1. Open the Create Macro dialog box by selecting Tools  [arrow] Macro [arrow]  Edit Macros...
  2. Enter the name of the macro.
  3. Enter a description of the macro.
  4. Click on Edit... to open the Select Commands dialog box.
  5. 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 [rarr] . 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 [darr] to move the command towards the end of the macro.
  6. When all commands are in the Macro Contents list box and are ordered correctly, click on OK.
  7. In the Create Macro dialog box, click on Add/Update.

To play a macro, use a keyboard shortcut or:

  1. Open the Play command dialog box by selecting Tools  [arrow] Macro [arrow] Play Macro
  2. From the Category list box, select User defined.
  3. From the Command list box, select the macro .
  4. Click on Play.

To edit a macro:

  1. Open the Create macro dialog box by selecting Tools  [arrow] Macro [arrow] Edit Macros...
  2. In the Current Macros list box, select the macro.
  3. Click on Edit to open the Select Commands dialog box.
  4. To add a command, select a command from the Available Commands list box and click on [rarr].
  5. 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.
  6. To delete a command, select the command in the Macro Contents list box and click on Delete.

To delete a macro,

  1. Select Tools  [arrow] Macro [arrow] Edit Macros...
  2. Select the macro from the Current Macros list box.
  3. Click on Delete Macro.
  4. Click on OK.


Example of Creating a Macro

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.

 

  1. Select View  [arrow] Enhanced Editor
  2. Select Tools  [arrow] Macro [arrow] Record New Macro
  3. In the Enhanced Editor window:
    1. Press Enter.
    2. Enter rsubmit
    3. Press Enter.
    4. Enter endrsubmit;
    5. Press the up arrow.
    6. Press the Tab key.
    7. Select Tools  [arrow] Macro [arrow]  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 ['|']


Adding Dates and Time

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



Bookmarking Lines

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



Finding and Replacing Text

To find text:

  1. Open the Find dialog box by selecting Edit  -> Find...
  2. 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.
  3. 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

  1. To search only within a subset of text, select the text.
  2. Open the Replace dialog box by selecting Edit -> Replace...
  3. 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.
  4. Click on Find Next.
  5. If the text if found, click on one of the following:


Moving the Cursor

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:

  1. Enter the key sequence Ctrl + G.
  2. Enter the line number.
  3. 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:

  1. Select Tools  -> Options -> Enhanced Editor...  -> General
  2. Select the Allow cursor movement past end of line check box
  3. 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

 

Selecting and Editing Text

 

Dragging and Dropping Text

To move or copy text in your file using drag and drop:

  1. Select Tools  -> Options -> Enhanced Editor... -> General
  2. Check the Drag and drop text editing check box and click on OK.
  3. Select the text to move or copy and hold down the mouse button.
  4. 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.


Using Line Numbers

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:

  1. Select Tools  -> Options -> Enhanced Editor
  2. Select Show line numbers to turn number on or deselect Show line numbers to turn numbers off.
  3. Click on OK.


Submitting Your Program

To submit your program, do one of the following:

 

 


Setting Enhanced Editor Options

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:

 


General Editor 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.


Format Options

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.


Setting Formatting Options

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:

  1. Open the Editor Options window by selecting Tools  -> Options -> Enhanced Editor...
  2. 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.
  3. Optionally, you can select a saved formatting scheme from the Scheme: drop-down list. For more information on using schemes, see Using Schemes.
  4. From the Font: drop-down list , select a font.
  5. From the Script: dropt-down list, select a script appropriate for the language your computer is set up on.
  6. For each file element you want to format:
    1. Select a file element.
    2. 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.
    3. 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.
    4. From the Font Style: drop-down list, select either Normal, Bold or Italic.
    5. If you want the element underlined, select the Underlined box.
  7. Review your selections in the Sample box. When you are done formatting all file elements, click on OK.


Using Schemes

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:

  1. Select a file type from the File type: drop-down list.
  2. Select a font and a script.
  3. For each file element, select a color for the foreground and background, a font style, and the underlining option.
  4. Click on Save As... and enter a scheme name in the Save Scheme dialog box.
  5. Click on OK.

To modify a scheme:

  1. Select a file type from the File type: drop-down list.
  2. Select a scheme.
  3. Make the font and file element changes you want.
  4. Click on Save As... The selected scheme name ought to be in the Scheme name entry box.
  5. Click on OK.

To delete a scheme:

  1. Select a file type.
  2. Select the scheme you want to delete.
  3. Click on the Delete button.

 


Customizing the Enhanced Editor Keyboard

MAIN

Last updated: 01/18/06 by Karl Ho