Chapter Contents |
Previous |
Next |
WINDOW |
Valid: | in a DATA step |
Category: | Window Display |
Type: | Declarative |
Syntax |
WINDOW window <window-options> field-definition(s); |
WINDOW window <window-options> group-definition(s); |
Restriction: | Window names must conform to SAS naming conventions. |
BLACK | MAGENTA |
BLUE | ORANGE |
BROWN | PINK |
CYAN | RED |
GRAY | WHITE |
GREEN | YELLOW |
Default: | If you do not specify a color with the COLOR= option, the window's background color is device-dependent instead of black, and the color of a field is device-dependent instead of white. |
Tip: | The representation of colors may vary, depending on the monitor being used. COLOR= has no effect on monochrome monitors. |
Default: | The window fills all remaining columns in the display; the number of columns that are available depends on the type of monitor that is being used. |
Default: | SAS displays the window at column 1. |
Default: | SAS displays the window at row 1. |
Default: | SAS uses the current function key settings that are defined in the KEYS window. |
Tip: | If you specify only an entry
name, SAS looks in the SASUSER.PROFILE catalog for a KEYS entry of the name
that is specified. You can also specify the three-level name of a KEYS entry,
in the form
libref.catalog.keys-entry |
Tip: | To create a set of function key definitions for a window, use the KEYS window. Define the keys as you want, and use the SAVE command to save the definitions in the SASUSER.PROFILE catalog or in a SAS data library and catalog that you specify. |
Tip: | If you specify only an entry
name, SAS looks in the SASUSER.PROFILE catalog for a PMENU entry of the name
specified. You can also specify the three-level name of a PMENU entry in the
form
libref.catalog.pmenu-entry |
Default: | The window fills all remaining rows in the display. |
Tip: | The number of rows that are available depends on the type of monitor that is being used. |
Tip: | A window or group can contain any number of fields, and you can define the same field in several groups or windows. |
Tip: | You can specify multiple field-definitions. |
See Also: | The form of field-definition is given in Field Definitions. |
Restriction: | group must be a SAS name. |
Default: | A window contains one unnamed group of fields. |
Tip: | When you refer to a group in a DISPLAY statement, write the name as window.group. |
Tip: | A group contains all fields in a window that you want to display at the same time. Display various groups of fields within the same window at different times by naming each group. Choose the group to appear by specifying window.group in the DISPLAY statement. |
Tip: | Specifying several groups within a window prevents repetition of window options that do not change and helps you to keep track of related displays. For example, if you are defining a window to check data values, arrange the display of variables and messages for most data values in the data set in a group that is named STANDARD. Arrange the display of different messages in a group that is named CHECKIT that appears when data values meet the conditions that you want to check. |
Details |
Operating Environment Information: The WINDOW statement has some functionality that is specific to your operating environment. For details, see the SAS documentation for your operating environment.
You can use the WINDOW statement in the SAS windowing environment, in interactive line mode, or in noninteractive mode to create customized windows for your applications.(footnote 1) Windows that you create can display text and accept input; they have command and message lines. The window name appears at the top of the window. Use commands and function keys with windows that you create. A window definition remains in effect only for the DATA step that contains the WINDOW statement.
Define a window before you display it. Use the DISPLAY
statement to display windows that are created with the WINDOW statement. For
information about the DISPLAY statement, see
DISPLAY.
Use a field definition to identify a variable or a character string to be displayed, its position, and its attributes. Enclose character strings in quotation marks. The position of an item is its beginning row (or line) and column. Attributes include color, whether you can enter a value into the field, and characteristics such as highlighting.
You can define a field to contain a variable value or a character string, but not both. The form of a field definition for a variable value is
<row column> variable <format> options |
The form for a character string is
<row column> 'character-string' options |
The elements of a field definition are described here.
Default: | If you omit row in the first field of a window or group, SAS uses the first row of the window; if you omit row in a later field specification, SAS continues on the row that contains the previous field. If you omit column, SAS uses column 1 (the left border of the window). |
Tip: | Although you can specify either row or column first, the examples in this book show the row first. |
SAS keeps track of its position in the window with a pointer. For example, when you tell SAS to write a variable's value in the third column of the second row of a window, the pointer moves to row 2, column 3 to write the value. Use the pointer controls that are listed here to move the pointer to the appropriate position for a field.
In a field definition, row can be one of these row pointer controls:
Range: | n must be a positive integer. |
Restriction: | #numeric-variable must be a positive integer. If the value is not an integer, the decimal portion is truncated and only the integer is used. |
Restriction: | expression can contain array references and must evaluate to a positive integer. |
Restriction: | Enclose expression in parentheses. |
In a field definition, column can be one of these column pointer controls:
Restriction: | n must be a positive integer. |
Restriction: | numeric-variable must be a positive integer. If the value is not an integer, the decimal portion is truncated and only the integer is used. |
Restriction: | expression can contain array references and must evaluate to a positive integer. |
Restriction: | Enclose expression in parentheses. |
Range: | n must be a positive integer. |
Restriction: | +numeric-variable must be a positive or negative integer. If the value is not an integer, the decimal portion is truncated and only the integer is used. |
Tip: | variable can be the name of a variable or of an array reference. |
Tip: | To allow a variable value in a field to be displayed but not changed by the user, use the PROTECT= option (described later in this section). You can also protect an entire window or group for the current execution of the DISPLAY statement by specifying the NOINPUT option in the DISPLAY statement. |
Tip: | If a field definition contains the name of a new variable, that variable is added to the data set that is being created (unless you use a KEEP or DROP specification). |
Default: | If you omit format, SAS uses an informat and format that are specified elsewhere (for example, in an ATTRIB, INFORMAT, or FORMAT statement or permanently stored with the data set) or a SAS default informat and format. |
Tip: | If a field displays a variable that cannot be changed (that is, you use the PROTECT=YES option), format can be any SAS format or a format that you define with the FORMAT procedure. |
Tip: | If a field can both display a variable and accept input, you must either specify the informat in an INFORMAT or ATTRIB statement or use a SAS format such as $CHAR. or TIME. that has a corresponding informat. |
Tip: | If a format is specified, the corresponding informat is assigned automatically to fields that can accept input. |
Tip: | A format and an informat in a WINDOW statement override an informat and a format that are specified elsewhere. |
Restriction: | The character string must be enclosed in quotation marks. |
Restriction: | You cannot enter a value in a field that contains a character string. |
Alias: | A= |
Tip: | To specify more than one highlighting attribute, use the form |
ATTR=(highlighting-attribute-1, . . . )
Tip: | The highlighting attributes that are available depend on the type of monitor that you use. |
YES | specifies that the cursor moves automatically to the next unprotected field. |
NO | specifies that the cursor does not move automatically. |
Alias: | AUTO= |
Default: | NO |
BLACK | MAGENTA |
BLUE | ORANGE |
BROWN | PINK |
CYAN | RED |
GRAY | WHITE |
GREEN | YELLOW |
Alias: | C= |
Default: | WHITE |
Tip: | The representation of colors may vary, depending on the monitor you use. |
Tip: | COLOR= has no effect on monochrome monitors. |
YES | specifies that SAS displays characters in a field as you type them in. | ||
NO | specifies that the entered characters
are not displayed.
|
YES | specifies that each execution of the DISPLAY statement displays all previously displayed contents of the field as well as those that are scheduled for display by the current DISPLAY statement. If the new contents overlap persisting contents, the persisting contents are no longer displayed. |
NO | specifies that each execution of a DISPLAY statement displays only the current contents of the field. |
Default: | NO |
Tip: | PERSIST= is most useful when the position of a field changes in each execution of a DISPLAY statement. |
Featured in: | Persisting and Nonpersisting Fields |
YES | specifies that you cannot enter information. |
NO | specifies that you can enter information. |
Alias: | P= |
Default: | No |
Tip: | Use PROTECT= only for fields that contain variables; fields that contain text are automatically protected. |
NO | specifies that you can leave the field blank. |
YES | specifies that you must enter a value in the field. |
Default: | NO |
Tip: | If you try to leave a field blank that was defined with REQUIRED=YES, SAS does not allow you to input values in any subsequent fields in the window. |
The WINDOW statement creates two automatic SAS variables: _CMD_ and _MSG_.
_CMD_ | contains the last command from the
window's command line that was not recognized by the window.
| ||||
_MSG_ | contains a message that you specify
to be displayed in the message area of the window.
|
The DISPLAY statement enables you to display windows. Once you display a window, the window remains visible until you display another window over it or until the end of the DATA step. When you display a window that contains fields into which you can enter values, either enter a value or press ENTER at each unprotected field to cause SAS to proceed to the next display. While a window is being displayed, you can use commands and function keys to view other windows, change the size of the current window, and so on. SAS execution proceeds to the next display only after you have pressed ENTER in all unprotected fields.
A DATA step that contains a DISPLAY statement continues execution until
Comparisons |
Examples |
This DATA step creates a window with a single group of fields:
data _null_; window start #9 @26 'WELCOME TO THE SAS SYSTEM' color=black #12 @19 'THIS PROGRAM CREATES' #12 @40 'TWO SAS DATA SETS' #14 @26 'AND USES THREE PROCEDURES' #18 @27 'Press ENTER to continue'; display start; stop; run;
The START window fills the entire display. The first line of text is black. The other three lines are the default for your operating environment. The text begins in the column that you specified in your program. The START window does not require you to input any values. However, to exit the window do one of the following:
If you omit the STOP statement from this program, the
DATA step executes endlessly until you execute END from the window, either
with a function key or from the command line. (Because this DATA step does
not read any observations, SAS cannot detect an end-of-file to end DATA step
execution.)
The following statements assign news articles to reporters. The list of article topics is stored as variable art in SAS data set category.article. This application allows you to assign each topic to a writer and to view the accumulating assignments. The program creates a new SAS data set named Assignment.
libname category 'SAS-data-library'; data Assignment; set category.article end=final; drop a b j s o; window Assignment irow=1 rows=12 color=white #3 @10 'Article:' +1 art protect=yes 'Name:' +1 name $14.; window Showtotal irow=20 rows=12 color=white group=subtotal #1 @10 'Adams has' +1 a #2 @10 'Brown has' +1 b #3 @10 'Johnson has' +1 j #4 @10 'Smith has' +1 s #5 @10 'Other has' +1 o group=lastmessage #8 @10 'ALL ARTICLES ASSIGNED. Press ENTER to stop processing.'; display Assignment blank; if name='Adams' then a+1; else if name='Brown' then b+1; else if name='Johnson' then j+1; else if name='Smith' then s+1; else o+1; display Showtotal.subtotal blank noinput; if final then display Showtotal.lastmessage; run;
When you execute the DATA step, the following windows appear.
In the Assignment window
(located at the top of the
display), you see the name of the article and a field into which you enter
a reporter's name. After you type a name and press ENTER, SAS displays the
Showtotal window (located at the bottom of the display) which shows the number
of articles that are assigned to each reporter (including the assignment that
you just made). As you continue to make assignments, the values in the Showtotal
window are updated. During the last iteration of the DATA step, SAS displays
the message that all articles are assigned, and instructs you to press ENTER
to stop processing.
This example demonstrates the PERSIST= option. You move from one window to the other by positioning the cursor in the current window and pressing ENTER.
data _null_; array row{3} r1-r3; array col{3} c1-c3; input row{*} col{*}; window One rows=20 columns=36 #1 @14 'PERSIST=YES' color=black #(row{i}) @(col{i}) 'Hello' color=black persist=yes; window Two icolumn=43 rows=20 columns=36 #1 @14 'PERSIST=NO' color=black #(row{i}) @(col{i}) 'Hello' color=black persist=no; do i=1 to 3; display One; display Two; end; datalines; 5 10 15 5 10 15 ;The following windows show the results of this DATA step after its third iteration.
Note
that window One shows
Hello
in all three positions
in which it was displayed. Window Two shows only the third and final position
in which
Hello
was displayed.
This example uses the _CMD_ and _MSG_ automatic variables to send a message when you execute an erroneous windowing command in a window that is defined with the WINDOW statement:
if _cmd_ ne ' ' then _msg_='CAUTION: UNRECOGNIZED COMMAND' || _cmd_;When you enter a command that contains an error, SAS sets the value of _CMD_ to the text of the erroneous command. Because the value of _CMD_ is no longer blank, the IF statement is true. The THEN statement assigns to _MSG_ the value that is created by concatenating CAUTION: UNRECOGNIZED COMMAND and the value of _CMD_ (up to a total of 80 characters). The next time a DISPLAY statement displays that window, the message line of the window displays
CAUTION: UNRECOGNIZED COMMAND commandCommand is the erroneous windowing command.
See Also |
Statements:
| |||
"The PMENU Procedure" in SAS Procedures Guide |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.