Chapter Contents

Previous

Next
SAS Companion for the Microsoft Windows Environment

Working within Your SAS Session

The following sections describe how to work within your SAS session. These features include the SAS Text Editor, the clipboard, special characters, SAS commands, and the SAS working folder.


Using the SAS Text Editor Windows

The SAS text editor windows (including Program Editor and NOTEPAD) work similar to other Windows editors. Thus, you can edit your SAS code without learning how to use a new text editor.

Using Line Numbers

If you are familiar with the SAS Program Editor window under other operating systems, such as OS/390, notice that under Windows line numbers are turned off by default. You can enter the NUMBERS ON command from the command box to display line numbers in the Program Editor window.

You can also control line numbers using the Editor Options dialog box when the Program Editor or Notepad is the active window. To open the Editor Options dialog box either type `edop' in the command box or:

  1. Select

    Tools
    [arrow]
    Options
    [arrow]
    Editor

  2. Click on the down-arrow in the combo box at the top of the Editor Options dialog box and select Text Editing Options.

  3. With the right mouse button select the Nums option.

  4. With the left mouse button, select Modify.

  5. In the Value combo box, select either Yes or No and click [OK].


Moving the Cursor

The cursor movement keys (arrow keys, PgUp, PgDn, and so on) function the same way in SAS text windows as they do in other Windows applications.

Pressing the CTRL key with the left arrow (word left) or right arrow (word right) causes the cursor to move one word at a time. When advancing through text, the word-left and word-right commands stop at the end of the text on a line and at the beginning of the first word on a new line. You can move to the top of a file by pressing CTRL+PgUp or to the bottom of a file by pressing CTRL+PgDn.

Pressing the Home key causes the cursor to go to the beginning of the current line unless the command line is active. Pressing the Home key when the command line is active causes the cursor to toggle between the current cursor position in the text and the command line. The F11 key moves the cursor to the command bar.

Using Tabs

Many text editors retain tab characters, while others expand tabs into space characters. The SAS Program Editor window expands tabs into space characters. Pressing the Tab key inserts spaces and moves any text to the right of the cursor.

By default, tabs are set on every 8th column. If you change the tab settings (using the TABS line command), the SAS System honors the new settings. If you remove all tab settings, the Tab key moves the cursor to the beginning of the next field and does not add any spaces to the text.

Understanding Line Breaks

Conceptually, line breaks are at the end of the line rather than at the beginning. Pressing the Enter key creates a line break. To delete a line break, press the Backspace key at the beginning of a line or press the Delete key at the end of the line.

Selecting Text

You can use the mouse or the SHIFT key in combination with the cursor movement keys to select text. The marking of an area of text continues until you release the mouse button or release the SHIFT key. To select all of the text in the active window, select the Edit menu and then select Select All. The following are some advanced text selection methods:

If characters are selected and you start typing text, the marked area is replaced with the new text. This occurs even if you have moved the cursor away from the marked area. For information about marking and copying text with a mouse, see Using the Clipboard.

To unmark text, click the left mouse button in the window. Alternatively, you can unmark text by selecting Deselect from the Edit menu or you can press the ESC key.

Deleting Text

The Delete key deletes the currently selected text, if there is any; otherwise, it deletes the character to the right of the cursor. To delete from the cursor to the end of the current line, press ALT+Delete. To delete from the cursor to the end of the current word, press CTRL+Delete. To delete from the cursor to the start of the current word, press CTRL+Backspace.

You can also use the Edit menu to delete text. To delete all text in the window, click Clear All. To delete only selected text, click Clear. To delete selected text and copy that text to the Windows clipboard, click Cut.

Dragging and Dropping Text

Summary of Text Drag and Drop Possibilities lists the places from which you can drag text and to which you can drop the selected text.

Summary of Text Drag and Drop Possibilities
Drag text from and drop it to
any SAS text window another SAS window that supports text editing (such as the Program Editor window
any SAS text window another Windows application that supports text drag and drop
a Windows application that supports text drag and drop any SAS window that supports editing
Windows Explorer (text file item) any SAS window that supports editing

To drag and drop text from one window to another:

  1. Arrange your windows, if necessary, so that both the source and target windows are visible on the display.

    Note:    Instead of arranging your windows so that the target window is visible, the target window will become the active window when you drag the selected text to the target window's button on the window bar.  [cautend]

  2. Select the desired text from the source window.

  3. Click and hold the left mouse button with the pointer on the selected text.

  4. With the mouse button still pressed, drag the text to the target window.

  5. Move the mouse pointer to the position where you want to insert the text. (If you plan to just submit the text as SAS code for processing, position the mouse pointer anywhere in the window).

  6. Release the mouse button. The text is either included at the point where you positioned the cursor, or it is submitted to the SAS System for processing. (The default action depends on the type of the target window.)

You can override the default action of the drag and drop by initiating the drag and drop using the right mouse button. This is called nondefault drag and drop. When you drag the selection to the target SAS window and release the mouse button, SAS displays a popup menu to let you choose which action to perform.

Summary of Drag-and-Drop Actions is a summary of drag-and-drop actions available for the possible target windows in SAS.

Summary of Drag-and-Drop Actions
Data Target Default
Action
Nondefault
Actions
text SAS text editor move move, copy, cancel
text PROGRAM

EDITOR

move move, copy, submit, cancel
file SAS text editor not valid not valid
file PROGRAM

EDITOR

move copy, submit, cancel
file LOG, OUTPUT submit submit, cancel

The actions that occur when you drag text out of a SAS window into another Windows application depend on the target application. In most cases, dragging and dropping text between SAS and other applications actually moves the text from one window to another (that is, the text is cut from one window and placed in the other).

You can change that behavior by applying a drag-modifier_a key you press while you drag and drop. To copy text from one window to another (instead of moving it), press and hold the CTRL key before and during the drag and drop. When you release the mouse button to drop the text, release the CTRL key as well.

Drag Scrolling

While dragging text to a SAS text editor window, you can cause the target window to scroll vertically or horizontally. This lets you drop text in a window area that is not currently visible.

Once you have selected the text and drag it to the SAS text editor window, pause near the border of the SAS text editor window. The window scrolls in the direction of that border. For example, to cause the target window to scroll down, drag the mouse pointer just above the bottom border of the window and pause.

Drag scrolling only happens when you pause near the drop area border; it does not occur if you drag quickly past the border.

Using Rich Text Format Text

When you copy text out of a SAS window to the clipboard and paste it into the window of another application, the text retains all of the format information it had in SAS (except for color) if the target window accepts RTF formatting. For example, the Windows Notepad application does not preserve formatting, but Microsoft Wordpad and many word processors do. The same is true when you drag text out of SAS and drop it in another application window.

If the display font is Sasfont, any text that you copy out of SAS is formatted with the SAS Monospace TrueType font. If your text has other highlighting attributes, such as underline, those attributes are also transferred to the target window in the other application (provided the target window supports rich text format (RTF)).

Understanding Unique Features of the Editor

The following features of the SAS Text Editor window are different from the standard features of other editors commonly used in the Windows environment:


Using the Clipboard

The Windows clipboard enables you to exchange text and graphics between applications. You can also submit SAS code stored on the clipboard. The clipboard uses operating system memory as an intermediate storage buffer for exchanging text and graphics. With the clipboard, you can move text between

The SAS System under Windows communicates with the clipboard using these formats:

SAS text format
preserves the text and color attributes between SAS sessions. This format is understood by the SAS System, but not by other Windows applications.

Windows text format
is understood by most Windows applications and is called the ANSI text format.

RTF text format
encapsulates text font and highlighting attributes when copying text between applications that both support RTF format. SAS can only cut and copy text in RTF format; you cannot paste RTF text into a SAS window.

Unicode text format (Windows only)
is a universal text format that can represent all possible characters. The format is also referred to as a wide-character format. For more information on this text format, see your Windows NT documentation.

Windows bitmap format
is for graphics, and windows in SAS/ASSIST software. This format is understood by most Windows applications and is called the BITMAP format.

Windows metafile (WMF) format
is used in many SAS applications that support the GSTORE command, such as the Graphics Editor in SAS/GRAPH software, SAS/QC software's ISHIKAWA procedure, and SAS/INSIGHT software. The metafile format provides more information about the image than the bitmap format and is sometimes called the PICTURE format.

DIB (Device Independent Bitmap) format
is used with color bitmap files. When a bitmap is stored in the DIB format, colors map correctly from one device to another.

These formats enable you to copy text and SAS bitmapped information (for example, from a graphic) to another application. You can also use the Print Screen and ALT+Print Screen keys to copy information from your SAS session to the clipboard. Pressing Print Screen places the entire display in bitmap form on the clipboard. Pressing ALT+Print Screen places just the SAS session (including any menus and scroll bars) or the active dialog box (if any) on the clipboard.

You can use the clipboard only if both the source and destination applications provide support for the clipboard facility and for the format you are using. Note that whereas some operating environments allow multiple paste buffers, the SAS System under Windows uses the Windows clipboard, which is a single buffer.

Selecting and Copying Text

For windows that contain text, such as the Program Editor, Notepad, Log, Output, and KEYS windows, you can hold down the left mouse button and drag the mouse to mark the area you want to cut or copy. The text area is immediately marked in reverse video while you are dragging the mouse. In text windows, you can scroll while you are dragging the mouse by moving the cursor beyond the border of the window in the direction you want to scroll. Release the mouse button when you have included all the text you want to copy.

To copy marked text to the clipboard, do one of the following:

To paste text that is stored on the clipboard, position the cursor in a text area in a window and do one of the following:

The text from the clipboard is pasted to the area you indicate. If there is already an area of selected text within the target window, the selected text is replaced with contents of the clipboard. You can paste text only into SAS windows that accept text input, such as Program Editor or the SAS Notepad.

Selecting and Copying in Non-Text Windows

For windows such as the GRAPH and SAS/ASSIST windows, an area is marked by a box, not by reverse video. The box indicates that the area you are marking is in bitmap format. After you finish marking an area, you can copy it to the clipboard. If the window you are working in has no Edit pop-up menu, you can use the following keys combinations to perform the copy and paste functions:
CTRL+C copies the selection to the clipboard.
CTRL+V pastes the contents of the clipboard.

Using the GSTORE Command

SAS/QC software's ISHIKAWA procedure and the Graphics Editor support the storing of metafile graphics format as well as bitmap formats to the clipboard. In the Graphics Editor, the area you mark is enclosed in a box, and you cannot scroll as you mark. The GSTORE command should be used to store the currently marked area (the entire screen when used with the ISHIKAWA procedure) to the Windows clipboard in device-dependent bitmap (BMP), device-independent bitmap (DIB), and metafile (PICTURE) graphical data formats. You can also select the Edit pull-down menu and then select Copy to store the marked area to the clipboard.

Pasting Bitmapped Information into Your SAS Session

Some windows, such as the BUILD: DISPLAY window for FRAME entries in SAS/AF software, let you paste bitmaps into the window. For more information, see Pasting an OLE Object from the Clipboard.

Also, you can paste bitmaps into the SAS/GRAPH window to import graphics. For more information, see Importing Graphics from Other Applications.

Submitting SAS Code from the Clipboard

The SAS System under Windows enables you to use the Windows clipboard to submit SAS code. This feature can be used to copy or cut SAS code from another application, such as the Windows Notepad or another text editor, and submit it to the SAS System for execution. This is also convenient for submitting the sample programs that are available in SAS online Help.

To submit SAS code stored on the clipboard, select the Run pull-down menu and then select Submit clipboard with the Program Editor window active. Alternatively, you can use the GSUBMIT command from the command line, with the following syntax:


gsubmit buf=default

The GSUBMIT command can be used to submit SAS code stored on the clipboard even if the Program Editor window is not the active window (or is closed). If you use the GSUBMIT command often, you may want to define an icon for it in the tool bar, or assign the GSUBMIT command to a function key. For more information about how to define toolbar icons, see Customizing the Toolbar.


Creating Text Highlighting and Special Characters

This section describes special character attributes and alternate ASCII characters.

Special Character Attributes

The SAS NOTEPAD and SAS/AF applications let you use extended color and highlight attributes for text. To access these attributes, press the ESC key and the appropriate letter or number to turn a color or attribute on or off. With this feature, you can alter the color or attributes of entire lines or individual words or letters. Valid colors and attributes, as well as the keys you use to implement them, are listed in Extended Color Key Sequences and Extended Attribute Key Sequences. You can type the letters for the colors in either uppercase or lowercase.

Extended Color Key Sequences
Key Color Key Color
ESC+A gray ESC+B blue
ESC+C cyan ESC+G green
ESC+K black ESC+M magenta
ESC+N brown ESC+O orange
ESC+P pink ESC+R red
ESC+W white ESC+Y yellow

Extended Attribute Key Sequences
Key Description
ESC+0 turns off all highlighting attributes.
ESC+2 turns on the underline attribute.
ESC+3 turns on the reverse-video attribute.


Alternate ASCII Characters

If you want to create alternate ASCII characters such as foreign language characters, you can use the ALT key in combination with the ASCII character code. Use the numeric keypad with Num Lock on to enter the character code. For a list of ASCII character codes and instructions about how to use the ALT key sequences, see your Windows documentation.


Issuing SAS Commands

The following sections describe various ways you can issue commands to the SAS System under Windows.

Using Menus to Issue Commands

Many commands are already assigned to menu items for the windows in which they apply. For example, selecting the Run pull-down menu and then selecting Submit in the Program Editor window is the same as entering SUBMIT on the Program Editor window command line.

The items in the menu bar and pop-up menu vary depending on the active window. This ensures that each menu item is valid and appropriate for the currently active window.

Using the Command Line to Issue Commands

If you want to use the command line to issue commands, from the Preferences dialog box View tab, select Command Line. (For more information, see Setting Session Preferences.) This places a command line in each SAS window. You can then enter commands at the command line in the window to which the commands apply. For example, the INCLUDE command applies in the Program Editor window, but not in the Log window.

Using the Command Bar or Dialog Box to Issue Commands

By default, SAS displays a command bar at the top of the window. You can also select to display a floating command dialog box instead. (For more information about how to do this, see Setting Session Preferences.) To move your cursor to the command bar or dialog box, press F11.

The command bar and Command dialog box offer a central location from which you can enter any SAS command, as long as the command is valid for the active window. If you enter a command that is not valid for the active window, SAS issues an error message.

The SAS System stores the commands that you enter in the command bar from session to session, and you can easily retrieve previously entered commands by selecting them from the drop-down list. SAS can store the commands either in order of the most recently entered or in order of the most frequently used. You can select your preferences for the command bar by using the Preferences dialog box (described in Setting Session Preferences) or by issuing the COMMAND command (described in COMMAND).

Using the Toolbar to Issue Commands

The toolbar provides a convenient way to issue commands that you use often. To submit a command using the tool bar, simply click on the tool button that represents the command you need. To learn which tools perform what commands, position the mouse pointer over a tool briefly to reveal the ToolTip for that button.

You can add or change the tools defined in the tool bar. For more information, see Customizing the Toolbar.


Changing the SAS Working Folder

The working folder is the operating system folder to which many SAS commands and actions apply. The SAS working folder is displayed in the status line at the bottom of the main SAS window. By default, the SAS System uses the current folder as the working folder when you begin your SAS session. You can specify a different default working folder by changing the Start In field on the Properties page for the SAS program shortcut.

You can also change the working folder during your SAS session. If you are running SAS interactively, you can use the interface to select a new folder. If you are running SAS in batch mode or if you want to change the folder as part of a SAS program, you can use the SAS X statement to issue operating system commands to change the folder.

Interactively Selecting a New Working Folder

To change the SAS working folder during your SAS session, double-click on the current folder display in the status line. Then use the Change Folder dialog box (shown in The Change Folder Dialog Box) to select a new working folder.

The Change Folder Dialog Box

[IMAGE]

If you organize your files so that each project has its own folder, then this Change Folder dialog box lets you quickly switch between projects. As you select different projects, the dialog box retains the directories you select in the Folder drop-down list control.

Using SAS Statements to Change the Working Folder

You can change the working drive and folder by submitting the change directory (CD or CHDIR) command with the X statement in SAS. The SAS System intercepts the change directory command and then changes drive commands and changes its working folder.

For example, the following statements change the working folder for your SAS session to the MYDATA folder and G:\SALES\JUNE folder, respectively:


x 'cd \mydata';
x 'cd g:\sales\june';

To simply change the working drive, you can submit a change drive command (the drive letter followed by a colon) such as the following:


x 'a:';


Chapter Contents

Previous

Next

Top of Page

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.