Previous Page | Next Page

Macro Statements

%WINDOW Statement



Defines customized windows.
Type: Macro statement
Restriction: Allowed in macro definitions or open code
See also:

%DISPLAY Statement

%INPUT Statement


Syntax
Details
Example
Creating an Application Welcome Window
Creating Macro Variables from Input Information

Syntax

%WINDOWwindow-name<window-option-1 <...window-option-n> group-definition-1 <...group-definition-n>>field-definition-1 <...field-definition-n>;

window-name

names the window. Window-name must be a SAS name.

window-option-1 <...window-option-n>

specifies the characteristics of the window as a whole. Specify all window options before any field or group definitions. These window options are available:

COLOR=color

specifies the color of the window background. The default color of the window and the contents of its fields are both device-dependent. Color can be one of these:

BLACK
BLUE
BROWN
CYAN
GRAY (or GREY)
GREEN
MAGENTA
ORANGE
PINK
RED
WHITE
YELLOW

Operating Environment Information:   The representation of colors might vary, depending on the display device you use. In addition, on some display devices the background color affects the entire window; on other display devices, it affects only the window border.  [cautionend]

COLUMNS=columns

specifies the number of display columns in the window, including borders. A window can contain any number of columns and can extend beyond the border of the display. This feature is useful when you need to display a window on a device larger than the one on which you developed it. By default, the window fills all remaining columns in the display.

Operating Environment Information:   The number of columns available depends on the type of display device you use. Also, the left and right borders each use from 0 to 3 columns on the display depending on your display device. If you create windows for display on different types of display devices, ensure that all fields can be displayed in the narrowest window.  [cautionend]

ICOLUMN=column

specifies the initial column within the display at which the window is displayed. By default, the macro processor begins the window at column 1 of the display.

IROW=row

specifies the initial row (line) within the display at which the window is displayed. By default, the macro processor begins the window at row 1 of the display.

KEYS=<<libref.>catalog.>keys-entry

specifies the name of a KEYS catalog entry that contains the function key definitions for the window. If you omit libref and catalog, SAS uses SASUSER.PROFILE.keys-entry.

If you omit the KEYS= option, SAS uses the current function key settings defined in the KEYS window.

MENU=<<libref.>catalog.>pmenu-entry

specifies the name of a menu you have built with the PMENU procedure. If you omit libref and catalog, SAS uses SASUSER.PROFILE.pmenu-entry.

ROWS=rows

specifies the number of rows in the window, including borders. A window can contain any number of rows and can extend beyond the border of the display device. This feature is useful when you need to display a window on a device larger than the one on which you developed it. If you omit a number, the window fills all remaining rows in the display device.

Operating Environment Information:   The number of rows available depends on the type of display device you use.  [cautionend]

group-definition

names a group and defines all fields within a group. The form of group definition is GROUP=group field-definition <. . . field-definition-n> where group names a group of fields that you want to display in the window collectively. A window can contain any number of groups of fields. If you omit the GROUP= option, the window contains one unnamed group of fields. Group must be a SAS name.


Organizing fields into groups enables you to create a single window with several possible contents. To refer to a particular group, use window.group.

field-definition

identifies and describes a macro variable or string you want to display in the window. A window can contain any number of fields.

You use a field to identify a macro variable value (or constant text) to be displayed, its position within the window, and its attributes. Enclose constant text in quotation marks. The position of a field is determined by beginning row and column. The attributes that you can specify include color, whether you can enter a value into the field, and characteristics such as highlighting.

The form of a field definition containing a macro variable is

<row> <column> macro-variable<field-length> <options>

The form of a field definition containing constant text is

<row> <column>'text' | "text"<options>

The elements of a field definition are

row

specifies the row (line) on which the macro variable or constant text is displayed. Each row specification consists of a pointer control and, usually, a macro expression that generates a number. These row pointer controls are available:

#macro-expression

specifies the row within the window given by the value of the macro expression. The macro expression must either be a positive integer or generate a positive integer.

/ (forward slash)

moves the pointer to column 1 of the next line.

The macro processor evaluates the macro expression when it defines the window, not when it displays the window. Thus, the row position of a field is fixed when the field is being displayed.

If you omit row in the first field of a group, the macro processor uses the first line of the window. If you omit row in a later field specification, the macro processor continues on the line from the previous field.

The macro processor treats the first usable line of the window as row 1 (that is, it excludes the border, command line or menu bar, and message line).

Specify either row or column first.

column

specifies the column in which the macro variable or constant text begins. Each column specification consists of a pointer control and, usually, a macro expression that generates a number. These column pointer controls are available:

@macro-expression

specifies the column within the window given by the value of the macro expression. The macro expression must either be a positive integer or generate a positive integer.

+macro-expression

moves the pointer the number of columns given by the value of the macro expression. The macro expression must either be a positive integer or generate a positive integer.

The macro processor evaluates the macro expression when it defines the window, not when it displays the window. Thus, the column position of a field is fixed when the field is being displayed.

The macro processor treats the column after the left border as column 1. If you omit column, the macro processor uses column 1.

Specify either column or row first.

macro-variable

names a macro variable to be displayed or to receive the value you enter at that position. The macro variable must either be a macro variable name (not a macro variable reference) or it must be a macro expression that generates a macro variable name.

By default, you can enter or change a macro variable value when the window containing the value is displayed. To display the value without changes, use the PROTECT= option.

CAUTION:
Do not overlap fields.

Do not let a field overlap another field displayed at the same time. Unexpected results, including the incorrect assignment of values to macro variables, might occur. (Some display devices treat adjacent fields with no intervening blanks as overlapping fields.) SAS writes a warning in the SAS log if fields overlap.  [cautionend]

field-length

is an integer specifying how many positions in the current row are available for displaying the macro variable's value or for accepting input. The maximum value of field-length is the number of positions remaining in the row. You cannot extend a field beyond one row.

Note:   The field length does not affect the length stored for the macro variable. The field length affects only the number of characters displayed or accepted for input in a particular field.  [cautionend]

If you omit field-length when the field contains an existing macro variable, the macro processor uses a field equal to the current length of the macro variable value. This value can be up to the number of positions remaining in the row or remaining until the next field begins.

CAUTION:
Specify a field length whenever a field contains a macro variable.

If the current value of the macro variable is null, as in a macro variable defined in a %GLOBAL or %LOCAL statement, the macro processor uses a field length of 0. You cannot input any characters into the field.  [cautionend]

If you omit field-length when the macro variable is created in that field, the macro processor uses a field length of zero. Specify a field length whenever a field contains a macro variable.

'text' | "text"

contains constant text to be displayed. The text must be enclosed in either single or double quotation marks. You cannot enter a value into a field containing constant text.

options

can include the following:

ATTR=attribute | (attribute-1 <. . . , attribute-n>) A=attribute | (attribute-1 <. . . , attribute-n>)

controls several display attributes of the field. The display attributes and combinations of display attributes available depend on the type of display device you use.

BLINK

causes the field to blink.

HIGHLIGHT

displays the field at high intensity.

REV_VIDEO

displays the field in reverse video.

UNDERLINE

underlines the field.

AUTOSKIP=YES | NO AUTO=YES | NO

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. If you specify AUTOSKIP=YES, the cursor moves automatically to the next unprotected field. If you specify AUTOSKIP=NO, the cursor does not move automatically. The default is AUTOSKIP=YES.

COLOR=color C=color

specifies a color for the field. The default color is device-dependent. Color can be one of these:

BLACK
BLUE
BROWN
CYAN
GRAY (or GREY)
GREEN
MAGENTA
ORANGE
PINK
WHITE
YELLOW
DISPLAY=YES | NO

determines whether the macro processor displays the characters you are entering into a macro variable value as you enter them. If you specify DISPLAY=YES (the default value), the macro processor displays the characters as you enter them. If you specify DISPLAY=NO, the macro processor does not display the characters as you enter them.

DISPLAY=NO is useful for applications that require users to enter confidential information, such as passwords. Use the DISPLAY= option only with fields containing macro variables; constant text is displayed automatically.

PROTECT=YES | NO P=YES | NO

controls whether information can be entered into a field containing a macro variable. If you specify PROTECT=NO (the default value), you can enter information. If you specify PROTECT=YES, you cannot enter information into a field. Use the PROTECT= option only for fields containing macro variables; fields containing text are automatically protected.

REQUIRED=YES | NO

determines whether you must enter a value for the macro variable in that field. If you specify REQUIRED=YES, you must enter a value into that field in order to remove the display from the window. You cannot enter a null value into a required field. If you specify REQUIRED=NO (the default value), you do not have to enter a value in that field in order to remove the display from the window. Entering a command on the command line of the window removes the effect of REQUIRED=YES.


Details

Use the %WINDOW statement to define customized windows that are controlled by the macro processor. These windows have command and message lines. You can use these windows to display text and accept input. In addition, you can invoke windowing environment commands, assign function keys, and use a menu generated by the PMENU facility.

You must define a window before you can display it. The %WINDOW statement defines macro windows; the %DISPLAY statement displays macro windows. Once defined, a macro window exists until the end of the SAS session, and you can display a window or redefine it at any point.

Defining a macro window within a macro definition causes the macro processor to redefine the window each time the macro executes. If you repeatedly display a window whose definition does not change, it is more efficient to do one of the following:

If a %WINDOW statement contains the name of a new macro variable, the macro processor creates that variable with the current scope. The %WINDOW statement creates two automatic macro variables.

SYSCMD

contains the last command from the window's command line that was not recognized by the windowing environment.

SYSMSG

contains text you specify to be displayed on the message line.

Note:   Windowing environment file management, scrolling, searching, and editing commands are not available to macro windows.  [cautionend]


Example


Example 1: Creating an Application Welcome Window

This %WINDOW statement creates a window with a single group of fields:

%window welcome color=white
           #5 @28 'Welcome to SAS.' attr=highlight
              color=blue
           #7 @15
              "You are executing Release &sysver on &sysday, &sysdate.."
           #12 @29 'Press ENTER to continue.';

The WELCOME window fills the entire display device. The window is white, the first line of text is blue, and the other two lines are black at normal intensity. The WELCOME window does not require you to input any values. However, you must press ENTER to remove the display from the window.

Note:   Two periods are a needed delimiter for the reference to the macro variables SYSVER, SYSDAY, and SYSDATE.  [cautionend]


Example 2: Creating Macro Variables from Input Information

The following example prompts for information and creates macro variables from that information:

%window info         
  #5 @5 'Please enter userid:'       
  #5 @26 id 8 attr=underline                
  #7 @5 'Please enter password:'            
  #7 @28 pass 8 attr=underline display=no;           
       
%display info;          
           
%put userid entered was &id;          
%put password entered was &pass;  

Previous Page | Next Page | Top of Page