Previous Page | Next Page

Using the SAS Windowing Environment

Working with Text


The SAS Text Editor

The SAS text editor is an editing facility that is available in the Editor and SAS NOTEPAD windows of Base SAS, SAS/FSP, and SAS/AF software. You can edit text from the command line and from any line on which code appears in an edit window.

This section provides information about commands that you can use to perform common text editing tasks by using the SAS text editor. For more information about all SAS windowing environment commands, see Using SAS Windowing Environment Command Types.


Moving and Rearranging Text

Some of the basics of moving, deleting, inserting, and copying single lines of text have already been reviewed. The rules are similar for working with a block of text; simply use double letters on the beginning and ending lines that you want to edit.

For example, alphabetizing the following list requires that you move a block of text. Note the MM (move) block command on lines 5 and 6 and the B line command on line 1 of the example.

b 001  c signifies the line command copy
00002  d signifies the line command delete
00003  i signifies the line command insert
00004  m signifies the line command move
mm 05  a signifies the line command after
mm 06  b signifies the line command before
00007  r signifies the line command repeat

Press the ENTER or RETURN key to execute the changes. Here are the results:

00001  a signifies the line command after
00002  b signifies the line command before
00003  c signifies the line command copy
00004  d signifies the line command delete
00005  i signifies the line command insert
00006  m signifies the line command move
00007  r signifies the line command repeat

Mastering a few more commands greatly increases the complexity of what you can do within the text editor. Several commands enable you to justify text. Specify the JL (justify left) command to left justify, the JR (justify right) command to right justify, and the JC (justify center) command to center text. To justify blocks of text, use the JJL, JJR, and JJC commands. For example, if you want to center the following text,

00001 Study of Advertising Responses
00002 Topnotch Hotel Website
00003 Conducted by Global Information, Inc.

then simply add the JJC block command on the first and last lines and press ENTER or RETURN.

You can also shift text right or left the number of spaces that you choose by executing the following set of line commands:

>[n]

shifts text to the right the number of spaces that you specify; the default is one space.

<[n]

shifts text to the left the number of spaces that you specify; the default is one space.

To shift a block of text left, specify the following command on the beginning and ending line numbers of the block:

<<[n]

Specify the following command to shift a block of text to the right:

>>[n]


Displaying Columns and Line Numbers

To display column numbers in the text editor, specify the COLS line command. This command is especially useful if you are writing an INPUT statement in column mode, as shown in the following figure:

Executing the COLS Command

[Executing the COLS Command]

To remove the COLS line command or any other pending line command, execute the RESET command on the command line. You can also execute the D (delete) line command on the line where you have specified the COLS command to achieve the same results.

The NUMBERS command numbers the data lines in the Editor and SAS NOTEPAD windows. Specify the following command to add numbers to the data lines:

numbers on

To remove the numbers, specify

numbers off

You can also use the NUMBERS command without an argument, executing the command once to turn numbers on, and again to turn them off.


Making Text Uppercase and Lowercase


Overview

Making text uppercase and lowercase involves two sets of commands to accomplish two kinds of tasks:

Command Action
CAPS changes the default
CU, CL line commands change the case of existing text


Changing the Default

To change the default case of text as you enter it, use the CAPS command. After you execute the CAPS command, the text that you enter is converted to uppercase as soon as you press ENTER or RETURN. Under some operating environments, with CAPS ON, characters that are entered or modified are translated into uppercase when you move the cursor from the line. Character strings that you specify with a FIND, RFIND, or BFIND command are interpreted as having been entered in uppercase unless you enclose the character strings in quotation marks.

For example, if you want to find the word value in the Log window, then on the command line, specify

find value

If the CAPS command has already been specified, then SAS searches for the word VALUE instead of value. You receive a message indicating that no occurrences of VALUE have been found, as shown in the following display:

The Results of the FIND Command with CAPS ON

[The Results of the FIND Command with CAPS ON]

However, specify the following command and SAS searches for the word value, and finds it:

find 'value'

Setting CAPS ON remains in effect until the end of your session or until you turn it off. You can execute the CAPS command by specifying

caps on

To discontinue the automatic uppercasing of text, specify

caps off

You can also use the CAPS command like a toggle switch, executing it once to turn the command on, and again to turn it off.


Changing the Case of Existing Text

To uppercase or lowercase text that has already been entered, use the line commands CU and CL. Execute the CU (case upper) command to uppercase a line of text and the CL (case lower) command to lowercase a line of text.

In the following example, the CU and CL line commands each mark a line of text that will be converted to uppercase and lowercase, respectively.

00001 Study of Gifted Seventh Graders
cu002 Burns County Schools, North Carolina
cl003 Conducted by Educomp, Inc.

Press ENTER or RETURN to execute the commands. The lines of text are converted as follows:

00001 Study of Gifted Seventh Graders
00002 BURNS COUNTY SCHOOLS, NORTH CAROLINA
00003 conducted by educomp, inc.

For a block of text, you have two choices. First, you can execute the CCU block command to uppercase a block of text and the CCL block command to lowercase a block of text. Position the block command on both the first and last lines of text that you want to convert. Second, you can designate a number of lines that you want to uppercase or lowercase by specifying a numeric argument, as shown below:

cu3 1 Study of Gifted Seventh Graders
00002 Burns County Schools, North Carolina
00003 Conducted by Educomp, Inc.

Press ENTER or RETURN to execute the command. The three lines of text are converted to uppercase, as shown below:

00001 STUDY OF GIFTED SEVENTH GRADERS
00002 BURNS COUNTY SCHOOLS, NORTH CAROLINA
00003 CONDUCTED BY EDUCOMP, INC.


Combining and Separating Text

You can combine and separate pieces of text with a number of line commands. With the TC (text connect) command, you can connect two lines of text. For example, if you want to join the following lines, then type the TC line command as shown below. Note that the second line is deliberately started in column 2 to create a space between the last word of the first line and the first word of the second line.

tc001 This study was conducted by
00002  Educomp, Inc., of Annapolis, Md.

Press ENTER or RETURN to execute the command. The lines appear as shown below:

00001 This study was conducted by Educomp, Inc., of Annapolis, Md.

Conversely, the TS (text split) command shifts text after the cursor's current position to the beginning of a new line.

Remember that you can also use a function key to execute the TC line command, the TS line command, or any other line command as long as you precede it with a colon.

Previous Page | Next Page | Top of Page