Statements |
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. |
specifies characteristics of the window as a whole. Specify these window-options before any field or GROUP= specifications:
specifies the color of the window background for operating environments that have this capability. In other operating environments, this option affects the color of the window border. The following colors are available:
BLACK | MAGENTA |
BLUE | ORANGE |
BROWN | PINK |
CYAN | RED |
GRAY | WHITE |
GREEN | YELLOW |
specifies the number of columns in the window.
Default: | The window fills all remaining columns on the monitor; the number of columns that are available depends on the type of monitor that is being used. |
specifies the initial column within the monitor at which the window is displayed.
Default: | SAS displays the window at column 1. |
specifies the initial row (or line) within the monitor at which the window is displayed.
Default: | SAS displays the window at row 1. |
specifies the name of a KEYS entry that contains the function key definitions for the window.
specifies the name of a menu (pmenu) you have built with the PMENU procedure.
specifies the number of rows (or lines) in the window.
Default: | The window fills all remaining rows on the monitor. |
Tip: | The number of rows that are available depends on the type of monitor that is being used. |
specifies and describes a variable or character string to be displayed in a window or within a group of related fields.
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. |
specifies a group and defines all fields within a group. A group definition consists of two parts: the GROUP= option and one or more field definitions.
specifies a group of related fields.
Details |
Operating Environment Information: The WINDOW statement has some functionality that might be 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 Statement.
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.
specifies the position of the variable or character string.
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:
specifies row n within the window.
Range: | n must be a positive integer. |
specifies the row within the window that is given by the value of numeric-variable.
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. |
specifies the row within the window that is given by the value of expression.
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:
specifies column n within the window.
Restriction: | n must be a positive integer. |
specifies the column within the window that is given by the value of numeric-variable.
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. |
specifies the column within the window that is given by the value of expression.
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. |
moves the pointer the number of columns that is given by the numeric-variable.
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. |
specifies a variable to be displayed or to be assigned the value that you enter at that position when the window is displayed.
gives the format for the variable.
contains the text of a character string to be displayed.
Restriction: | The character string must be enclosed in quotation marks. |
Restriction: | You cannot enter a value in a field that contains a character string. |
Specify field definition attributes:
controls these highlighting attributes of the field:
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. |
controls whether the cursor moves to the next unprotected field of the current window or group when you have entered data in all positions of a field.
YES |
specifies that the cursor moves automatically to the next unprotected field. |
NO |
Alias: | AUTO= |
Default: | NO |
specifies a color for the variable or character string. You can specify one of the following colors:
BLACK | MAGENTA |
BLUE | ORANGE |
BROWN | PINK |
CYAN | RED |
GRAY | WHITE |
GREEN | YELLOW |
Alias: | C= |
Default: | WHITE |
Tip: | The representation of colors might vary, depending on the monitor you use. |
Tip: | COLOR= has no effect on monochrome monitors. |
controls whether the contents of a field are displayed.
YES |
specifies that SAS displays characters in a field as you type them in. | ||
NO |
specifies that the entered characters are not displayed.
|
controls whether a field is displayed by all executions of a DISPLAY statement in the same iteration of the DATA step until the DISPLAY statement contains the BLANK option.
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 |
controls whether information can be entered into a field.
YES | |
NO |
Alias: | P= |
Default: | No |
Tip: | Use PROTECT= only for fields that contain variables; fields that contain text are automatically protected. |
controls whether a field can be left blank.
NO | |
YES |
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. The 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
the last observation that is read by a SET, MERGE, MODIFY, UPDATE, or INPUT statement has been processed
Comparisons |
The WINDOW statement creates a window, and the DISPLAY statement displays it.
The %WINDOW and %DISPLAY statements in the macro language create and display windows that are controlled by the macro facility.
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 monitor. 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-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 monitor), 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 monitor) 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 command
Command is the erroneous windowing command.
The following statements create a SAS data set by using input from the WINDOW statement.
data new; length name $20; window start #3 @20 'Type the variable name' #4 @20 'and press the Enter key.' #7 'Name:' +1 name attr=underline #11 'When you are finished entering variable names, type "end"' #12 'at the command line.'; display start; run; proc print; run;
See Also |
| |||
FOOTNOTE 1: You cannot use the WINDOW statement in batch mode because no computer is connected to a batch executing process.
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.