Examples: PMENU Procedure


The windows in these examples were produced in the UNIX environment and may appear slightly different from the same windows in other operating environments.

You should know the operating environment-specific system options that can affect how menus are displayed and merged with existing SAS menus . For details, see the SAS documentation for your operating environment.

Example 1: Building a Menu Bar for an FSEDIT Application

Procedure features:

  • PROC PMENU statement option:

    • CATALOG=

  • ITEM statement options:

    • MENU=

    • SELECTION=

    • SUBMENU=

  • MENU statement

  • SELECTION statement

  • SUBMENU statement

This example creates a menu bar that can be used in an FSEDIT application to replace the default menu bar. The selections available on these pull-down menus do not enable end users to delete or duplicate observations.

Program

Declare the PROCLIB library. The PROCLIB library is used to store menu definitions.

 libname proclib  'SAS-data-library'  ; 

Specify the catalog for storing menu definitions. Menu definitions will be stored in the PROCLIB.MENUCAT catalog.

 proc pmenu catalog=proclib.menucat; 

Specify the name of the catalog entry. The MENU statement specifies PROJECT as the name of the catalog entry. The menus are stored in the catalog entry PROCLIB.MENUCAT.PROJECT.PMENU.

 menu project; 

Design the menu bar. The ITEM statements specify the items for the menu bar. The value of the MENU= option is used in a subsequent MENU statement. The Edit item uses a common predefined submenu; the menus for the other items are defined in this PROC step.

 item 'File' menu=f;  item 'Edit' submenu=editmnu;  item 'Scroll' menu=s;  item 'Help' menu=h; 

Design the File menu. This group of statements defines the selections available under File on the menu bar. The first ITEM statement specifies Goback as the first selection under File . The value of the SELECTION= option corresponds to the subsequent SELECTION statement, which specifies END as the command that is issued for that selection. The second ITEM statement specifies that the SAVE command is issued for that selection.

 menu f;     item 'Goback' selection=g;     item 'Save';     selection g 'end'; 

Add the EDITMNU submenu. The SUBMENU statement associates a predefined submenu that is located in the SAS file SASHELP. CORE .EDIT with the Edit item on the menu bar. The name of this SUBMENU statement is EDITMNU , which corresponds with the name in the SUBMENU= action-option in the ITEM statement for the Edit item.

 submenu editmnu sashelp.core.edit; 

Design the Scroll menu. This group of statements defines the selections available under Scroll on the menu bar.

 menu s;     item 'Next Obs' selection=n;     item 'Prev Obs' selection=p;     item 'Top';     item 'Bottom';     selection n 'forward';     selection p 'backward'; 

Design the Help menu. This group of statements defines the selections available under Help on the menu bar. The SETHELP command specifies a HELP entry that contains user -written information for this FSEDIT application. The semicolon that appears after the HELP entry name enables the HELP command to be included in the string. The HELP command invokes the HELP entry.

 menu h;          item 'Keys';          item 'About this application' selection=hlp;          selection hlp 'sethelp user.menucat.staffhlp.help;help';  quit; 

Associating a Menu Bar with an FSEDIT Session

The following SETPMENU command associates the customized menu bar with the FSEDIT window.

 setpmenu proclib.menucat.project.pmenu;pmenu on 

You can also specify the menu bar on the command line in the FSEDIT session or by issuing a CALL EXECCMD command in SAS Component Language (SCL).

See Associating a Menu Bar with an FSEDIT Session on page 707 for other methods of associating the customized menu bar with the FSEDIT window.

The FSEDIT window shows the menu bar.

click to expand

Example 2: Collecting User Input in a Dialog Box

Procedure features:

  • DIALOG statement

  • TEXT statement option:

    • LEN=

This example adds a dialog box to the menus created in Example 1 on page 698. The dialog box enables the user to use a WHERE clause to subset the SAS data set.

Tasks include

  • collecting user input in a dialog box

  • creating customized menus for an FSEDIT application.

Program

Declare the PROCLIB library. The PROCLIB library is used to store menu definitions.

 libname proclib '  SAS-data-library  '; 

Specify the catalog for storing menu definitions. Menu definitions will be stored in the PROCLIB.MENUCAT catalog.

 proc pmenu catalog=proclib.menucat; 

Specify the name of the catalog entry. The MENU statement specifies PROJECT as the name of the catalog entry. The menus are stored in the catalog entry PROCLIB.MENUCAT.PROJECT.PMENU.

 menu project; 

Design the menu bar. The ITEM statements specify the items for the menu bar. The value of the MENU= option is used in a subsequent MENU statement.

 item 'File' menu=f;  item 'Edit' menu=e;  item 'Scroll' menu=s;  item 'Subset' menu=sub;  item 'Help' menu=h; 

Design the File menu. This group of statements defines the selections under File on the menu bar. The first ITEM statement specifies Goback as the first selection under File . The value of the SELECTION= option corresponds to the subsequent SELECTION statement, which specifies END as the command that is issued for that selection. The second ITEM statement specifies that the SAVE command is issued for that selection.

 menu f;     item 'Goback' selection=g;     item 'Save';     selection g 'end'; 

Design the Edit menu. This group of statements defines the selections available under Edit on the menu bar.

 menu e;     item 'Cancel';     item 'Add'; 

Design the Scroll menu. This group of statements defines the selections available under Scroll on the menu bar.

 menu s;     item 'Next Obs' selection=n;     item 'Prev Obs' selection=p;     item 'Top';     item 'Bottom';     selection n 'forward';     selection p 'backward'; 

Design the Subset menu. This group of statements defines the selections available under Subset on the menu bar. The value d1 in the DIALOG= option is used in the subsequent DIALOG statement.

 menu sub;     item 'Where' dialog=d1;     item 'Where Clear'; 

Design the Help menu. This group of statements defines the selections available under Help on the menu bar. The SETHELP command specifies a HELP entry that contains user-written information for this FSEDIT application. The semicolon enables the HELP command to be included in the string. The HELP command invokes the HELP entry.

 menu h;     item 'Keys';     item 'About this application' selection=hlp;     selection hlp 'sethelp proclib.menucat.staffhlp.help;help'; 

Design the dialog box. The DIALOG statement builds a WHERE command. The arguments for the WHERE command are provided by user input into the text entry fields described by the three TEXT statements. The @1 notation is a placeholder for user input in the text field. The TEXT statements specify the text in the dialog box and the length of the input field.

 dialog d1 'where @1';           text #2 @3 'Enter a valid WHERE clause or UNDO';           text #4 @3 'WHERE ';           text #4 @10 len=40;  quit; 

Associating a Menu Bar with an FSEDIT Window

The following SETPMENU command associates the customized menu bar with the FSEDIT window.

 setpmenu proclib.menucat.project.pmenu;pmenu on 

You can also specify the menu bar on the command line in the FSEDIT session or by issuing a CALL EXECCMD command in SAS Component Language (SCL). Refer to SAS Component Language: Reference for complete documentation on SCL.

See Associating a Menu Bar with an FSEDIT Session on page 707 for other methods of associating the customized menu bar with the FSEDIT window.

This dialog box appears when the user chooses Subset and then Where .

click to expand

Example 3: Creating a Dialog Box to Search Multiple Variables

Procedure features:

  • DIALOG statement

    • SAS macro invocation

  • ITEM statement

    • DIALOG= option

  • RADIOBOX statement option:

    • DEFAULT=

  • RBUTTON statement option:

    • SUBSTITUTE=

Other features: SAS macro invocation

This example shows how to modify the menu bar in an FSEDIT session to enable a search for one value across multiple variables. The example creates customized menus to use in an FSEDIT session. The menu structure is the same as in the preceding example, except for the WHERE dialog box.

When selected, the menu item invokes a macro. The user input becomes values for macro parameters. The macro generates a WHERE command that expands to include all the variables needed for the search.

Tasks include

  • associating customized menus with an FSEDIT session

  • searching multiple variables with a WHERE clause

  • extending PROC PMENU functionality with a SAS macro.

Program

Declare the PROCLIB library. The PROCLIB library is used to store menu definitions.

 libname proclib '  SAS-data-library  '; 

Specify the catalog for storing menu definitions. Menu definitions will be stored in the PROCLIB.MENUCAT catalog.

 proc pmenu catalog=proclib.menucat; 

Specify the name of the catalog entry. The MENU statement specifies STAFF as the name of the catalog entry. The menus are stored in the catalog entry PROCLIB.MENUCAT.PROJECT.PMENU.

 menu project; 

Design the menu bar. The ITEM statements specify the items for the menu bar. The value of the MENU= option is used in a subsequent MENU statement.

 item 'File' menu=f;  item 'Edit' menu=e;  item 'Scroll' menu=s;  item 'Subset' menu=sub;  item 'Help' menu=h; 

Design the File menu. This group of statements defines the selections under File on the menu bar. The first ITEM statement specifies Goback as the first selection under File . The value of the SELECTION= option corresponds to the subsequent SELECTION statement, which specifies END as the command that is issued for that selection. The second ITEM statement specifies that the SAVE command is issued for that selection.

 menu f;     item 'Goback' selection=g;     item 'Save';     selection g 'end'; 

Design the Edit menu. The ITEM statements define the selections under Edit on the menu bar.

 menu e;     item 'Cancel';     item 'Add'; 

Design the Scroll menu. This group of statements defines the selections under Scroll on the menu bar. If the quoted string in the ITEM statement is not a valid command, then the SELECTION= option corresponds to a subsequent SELECTION statement, which specifies a valid command.

 menu s;     item 'Next Obs' selection=n;     item 'Prev Obs' selection=p;     item 'Top';     item 'Bottom';     selection n 'forward';     selection p 'backward'; 

Design the Subset menu. This group of statements defines the selections under Subset on the menu bar. The DIALOG= option names a dialog box that is defined in a subsequent DIALOG statement.

 menu sub;     item 'Where' dialog=d1;     item 'Where Clear'; 

Design the Help menu. This group of statements defines the selections under Help on the menu bar. The SETHELP command specifies a HELP entry that contains user-written information for this FSEDIT application. The semicolon that appears after the HELP entry name enables the HELP command to be included in the string. The HELP command invokes the HELP entry.

 menu h;     item 'Keys';     item 'About this application' selection=hlp;     selection hlp 'sethelp proclib.menucat.staffhlp.help;help'; 

Design the dialog box. WBUILD is a SAS macro. The double percent sign that precedes WBUILD is necessary to prevent PROC PMENU from expecting a field number to follow. The field numbers %1, %2, and %3 equate to the values that the user specified with the radio boxes. The field number @1 equates to the search value that the user enters. See How the WBUILD Macro Works on page 709.

 dialog d1 '%%wbuild(%1,%2,@1,%3)'; 

Add a radio box for region selection. The TEXT statement specifies text for the dialog box that appears on line 1 and begins in column 1. The RADIOBOX statement specifies that a radio box will appear in the dialog box. DEFAULT= specifies that the first radio button ( Northeast ) will be selected by default. The RBUTTON statements specify the mutually exclusive choices for the radio buttons : Northeast , Northwest , Southeast , or Southwest . SUBSTITUTE= gives the value that is substituted for the %1 in the DIALOG statement above if that radio button is selected.

 text #1 @1 'Choose a region:';  radiobox default=1;     rbutton #3 @5 'Northeast' substitute='NE';     rbutton #4 @5 'Northwest' substitute='NW';     rbutton #5 @5 'Southeast' substitute='SE';     rbutton #6 @5 'Southwest' substitute='SW'; 

Add a radio box for pollutant selection. The TEXT statement specifies text for the dialog box that appears on line 8 (#8) and begins in column 1 (@1). The RADIOBOX statement specifies that a radio box will appear in the dialog box. DEFAULT= specifies that the first radio button ( Pollutant A ) will be selected by default. The RBUTTON statements specify the mutually exclusive choices for the radio buttons: Pollutant A or Pollutant B . SUBSTITUTE= gives the value that is substituted for the %2 in the preceding DIALOG statement if that radio button is selected.

 text #8 @1 'Choose a contaminant:';  radiobox default=1;     rbutton #10 @5  'Pollutant A' substitute='pol_a,2';     rbutton #11 @5  'Pollutant B' substitute='pol_b,4'; 

Add an input field. The first TEXT statement specifies text for the dialog box that appears on line 13 and begins in column 1. The second TEXT statement specifies an input field that is 6 bytes long that appears on line 13 and begins in column 25. The value that the user enters in the field is substituted for the @1 in the preceding DIALOG statement.

 text #13 @1 'Enter Value for Search:';  text #13 @25 len=6; 

Add a radio box for comparison operator selection. The TEXT statement specifies text for the dialog box that appears on line 15 and begins in column 1. The RADIOBOX statement specifies that a radio box will appear in the dialog box. DEFAULT= specifies that the first radio button ( Greater Than or Equal To ) will be selected by default. The RBUTTON statements specify the mutually exclusive choices for the radio buttons. SUBSTITUTE= gives the value that is substituted for the %3 in the preceding DIALOG statement if that radio button is selected.

 text #15 @1 'Choose a comparison criterion:';             radiobox default=1;                rbutton #16 @5 'Greater Than or Equal To'                                substitute='GE';                rbutton #17 @5 'Less Than or Equal To'                                substitute='LE';                rbutton #18 @5 'Equal To' substitute='EQ';  quit; 

This dialog box appears when the user selects Subset and then Where .

click to expand

Associating a Menu Bar with an FSEDIT Session

The SAS data set PROCLIB.LAKES has data about several lakes. Two pollutants, pollutant A and pollutant B, were tested at each lake. Tests were conducted for pollutant A twice at each lake, and the results are recorded in the variables POL_A1 and POL_A2. Tests were conducted for pollutant B four times at each lake, and the results are recorded in the variables POL_B1 - POL_B4. Each lake is located in one of four regions . The following output lists the contents of PROCLIB.LAKES:

Output 34.1
start example
 PROCLIB.LAKES                                 1  region   lake         pol_a1    pol_a2    pol_b1    pol_b2    pol_b3    pol_b4    NE     Carr          0.24      0.99      0.95      0.36      0.44      0.67    NE     Duraleigh     0.34      0.01      0.48      0.58      0.12      0.56    NE     Charlie       0.40      0.48      0.29      0.56      0.52      0.95    NE     Farmer        0.60      0.65      0.25      0.20      0.30      0.64    NW     Canyon        0.63      0.44      0.20      0.98      0.19      0.01    NW     Morris        0.85      0.95      0.80      0.67      0.32      0.81    NW     Golf          0.69      0.37      0.08      0.72      0.71      0.32    NW     Falls         0.01      0.02      0.59      0.58      0.67      0.02    SE     Pleasant      0.16      0.96      0.71      0.35      0.35      0.48    SE     Juliette      0.82      0.35      0.09      0.03      0.59      0.90    SE     Massey        1.01      0.77      0.45      0.32      0.55      0.66    SE     Delta         0.84      1.05      0.90      0.09      0.64      0.03    SW     Alumni        0.45      0.32      0.45      0.44      0.55      0.12    SW     New Dam       0.80      0.70      0.31      0.98      1.00      0.22    SW     Border        0.51      0.04      0.55      0.35      0.45      0.78    SW     Red           0.22      0.09      0.02      0.10      0.32      0.01 
end example
 

A DATA step on page 1407 creates PROCLIB.LAKES.

The following statements initiate a PROC FSEDIT session for PROCLIB.LAKES:

 proc fsedit data=proclib.lakes screen=proclib.lakes;  run; 

To associate the customized menu bar menu with the FSEDIT session, do any one of the following:

  • enter a SETPMENU command on the command line. The command for this example is

     setpmenu proclib.menucat.project.pmenu 

    Turn on the menus by entering PMENU ON on the command line.

  • enter the SETPMENU command in a Command window.

  • include an SCL program with the FSEDIT session that uses the customized menus and turns on the menus, for example:

     fseinit:    call execcmd('setpmenu proclib.menucat.project.pmenu;                  pmenu on;');  return;  init:  return;  main:  return;  term:  return; 

How the WBUILD Macro Works

Consider how you would learn whether any of the lakes in the Southwest region tested for a value of .50 or greater for pollutant A. Without the customized menu item, you would issue the following WHERE command in the FSEDIT window:

 where region="SW" and (pol_a1 ge .50 or pol_a2 ge .50); 

Using the custom menu item, you would select Southwest , Pollutant A , enter .50 as the value, and choose Greater Than or Equal To as the comparison criterion. Two lakes, New Dam and Border , meet the criteria.

The WBUILD macro uses the four pieces of information from the dialog box to generate a WHERE command:

  • One of the values for region, either NE , NW , SE , or SW , becomes the value of the macro parameter REGION.

  • Either pol_a,2 or pol_b,4 become the values of the PREFIX and NUMVAR macro parameters. The comma is part of the value that is passed to the WBUILD macro and serves to delimit the two parameters, PREFIX and NUMVAR.

  • The value that the user enters for the search becomes the value of the macro parameter VALUE.

  • The operator that the user chooses becomes the value of the macro parameter OPERATOR.

To see how the macro works, again consider the following example, in which you want to know if any of the lakes in the southwest tested for a value of .50 or greater for pollutant A. The values of the macro parameters would be

REGION

SW

PREFIX

pol_a

NUMVAR

2

VALUE

.50

OPERATOR

GE

The first %IF statement checks to make sure that the user entered a value. If a value has been entered, then the macro begins to generate the WHERE command. First, the macro creates the beginning of the WHERE command:

 where region="SW" and ( 

Next, the %DO loop executes. For pollutant A, it executes twice because NUMVAR=2. In the macro definition, the period in & prefix. & i concatenates pol_a with 1 and with 2 . At each iteration of the loop, the macro resolves PREFIX, OPERATOR, and VALUE, and it generates a part of the WHERE command. On the first iteration, it generates pol_a1 GE .50

The %IF statement in the loop checks to see if the loop is working on its last iteration. If it is not working, then the macro makes a compound WHERE command by putting an OR between the individual clauses. The next part of the WHERE command becomes OR pol_a2 GE .50

The loop ends after two executions for pollutant A, and the macro generates the end of the WHERE command:

 ) 

Results from the macro are placed on the command line. The following code is the definition of the WBUILD macro. The underlined code shows the parts of the WHERE command that are text strings that the macro does not resolve:

 %macro wbuild(region,prefix,numvar,value,operator);         /* check to see if value is present */      %if &value ne %then %do;   where region   ="&region"   AND (   /* If the values are character,     */                 /* enclose &value in double quotation marks. */           %do i=1 %to &numvar;               &prefix.&i &operator &value                  /* if not on last variable,  */                  /* generate 'OR'             */              %if &i ne &numvar %then %do;   OR   %end;           %end;   )   %end;  %mend wbuild; 

Example 4: Creating Menus for a DATA Step Window Application

Procedure features:

  • DIALOG statement

  • SELECTION statement

Other features: FILENAME statement

This example defines an application that enables the user to enter human resources data for various departments and to request reports from the data sets that are created by the data entry.

The first part of the example describes the PROC PMENU step that creates the menus. The subsequent sections describe how to use the menus in a DATA step window application.

Tasks include

  • associating customized menus with a DATA step window

  • creating menus for a DATA step window

  • submitting SAS code from a menu selection

  • creating a pull-down menu selection that calls a dialog box.

Program

Declare the PROCLIB library. The PROCLIB library is used to store menu definitions.

 libname proclib '  SAS-data-library  '; 

Declare the DE and PRT filenames. The FILENAME statements define the external files in which the programs to create the windows are stored.

 filename de  '  external-file  ';  filename prt '  external-file  '; 

Specify the catalog for storing menu definitions. Menu definitions will be stored in the PROCLIB.MENUCAT catalog.

 proc pmenu catalog=proclib.menus; 

Specify the name of the catalog entry. The MENU statement specifies SELECT as the name of the catalog entry. The menus are stored in the catalog entry PROCLIB.MENUS.SELECT.PMENU.

 menu select; 

Design the menu bar. The ITEM statements specify the three items on the menu bar. The value of the MENU= option is used in a subsequent MENU statement.

 item 'File' menu=f;     item 'Data_Entry' menu=deptsde;     item 'Print_Report' menu=deptsprt; 

Design the File menu. This group of statements defines the selections under File . The value of the SELECTION= option is used in a subsequent SELECTION statement.

 menu f;     item 'End this window' selection=endwdw;     item 'End this SAS session' selection=endsas;     selection endwdw 'end';     selection endsas 'bye'; 

Design the Data_Entry menu. This group of statements defines the selections under Data_Entry on the menu bar. The ITEM statements specify that For Dept01 and For Dept02 appear under Data_Entry . The value of the SELECTION= option equates to a subsequent SELECTION statement, which contains the string of commands that are actually submitted. The value of the DIALOG= option equates to a subsequent DIALOG statement, which describes the dialog box that appears when this item is selected.

 menu deptsde;     item 'For Dept01' selection=de1;     item 'For Dept02' selection=de2;     item 'Other Departments' dialog=deother; 

Specify commands under the Data_Entry menu. The commands in single quotation marks are submitted when the user selects For Dept01 or For Dept02 . The END command ends the current window and returns to the PROGRAM EDITOR window so that further commands can be submitted. The INCLUDE command includes the SAS statements that create the data entry window. The CHANGE command modifies the DATA statement in the included program so that it creates the correct data set. (See Using a Data Entry Program on page 714.) The SUBMIT command submits the DATA step program.

 selection de1 'end;pgm;include de;change xx 01;submit';  selection de2 'end;pgm;include de;change xx 02;submit'; 

Design the DEOTHER dialog box. The DIALOG statement defines the dialog box that appears when the user selects Other Departments . The DIALOG statement modifies the command string so that the name of the department that is entered by the user is used to change deptxx in the SAS program that is included. (See Using a Data Entry Program on page 714.) The first two TEXT statements specify text that appears in the dialog box. The third TEXT statement specifies an input field. The name that is entered in this field is substituted for the @1 in the DIALOG statement.

 dialog deother 'end;pgm;include de;c deptxx @1;submit';     text #1 @1 'Enter department name';     text #2 @3 'in the form DEPT99:';     text #2 @25 len=7; 

Design the Print_Report menu. This group of statements defines the choices under the Print_Report item. These ITEM statements specify that For Dept01 and For Dept02 appear in the pull-down menu. The value of the SELECTION= option equates to a subsequent SELECTION statement, which contains the string of commands that are actually submitted.

 menu deptsprt;     item 'For Dept01' selection=prt1;     item 'For Dept02' selection=prt2;     item 'Other Departments' dialog=prother; 

Specify commands for the Print_Report menu. The commands in single quotation marks are submitted when the user selects For Dept01 or For Dept02 . The END command ends the current window and returns to the PROGRAM EDITOR window so that further commands can be submitted. The INCLUDE command includes the SAS statements that print the report. (See Printing a Program on page 715.) The CHANGE command modifies the PROC PRINT step in the included program so that it prints the correct data set. The SUBMIT command submits the

PROC PRINT program.

 selection prt1        'end;pgm;include prt;change xx 01 all;submit';  selection prt2        'end;pgm;include prt;change xx 02 all;submit'; 

Design the PROTHER dialog box. The DIALOG statement defines the dialog box that appears when the user selects Other Departments . The DIALOG statement modifies the command string so that the name of the department that is entered by the user is used to change deptxx in the SAS program that is included. (See Printing a Program on page 715.) The first two TEXT statements specify text that appears in the dialog box. The third TEXT statement specifies an input field. The name entered in this field is substituted for the @1 in the DIALOG statement.

 dialog prother 'end;pgm;include prt;c deptxx @1 all;submit';     text #1 @1 'Enter department name';     text #2 @3 'in the form DEPT99:';     text #2 @25 len=7; 

End this RUN group.

 run; 

Specify a second catalog entry and menu bar. The MENU statement specifies ENTRDATA as the name of the catalog entry that this RUN group is creating. File is the only item on the menu bar. The selections available are End this window and End this SAS session .

 menu entrdata;         item 'File' menu=f;         menu f;            item 'End this window' selection=endwdw;            item 'End this SAS session' selection=endsas;            selection endwdw 'end';            selection endsas 'bye';     run;  quit; 

Associating a Menu with a Window

The first group of statements defines the primary window for the application. These statements are stored in the file that is referenced by the HRWDW fileref:

The WINDOW statement creates the HRSELECT window. MENU= associates the PROCLIB.MENUS.SELECT.PMENU entry with this window.

 data _null_;     window hrselect menu=proclib.menus.select     #4  @10 'This application allows you to'     #6  @13 '- Enter human resources data for'     #7  @15 'one department at a time.'     #9  @13 '- Print reports on human resources data for'     #10 @15 'one department at a time.'     #12 @13 '- End the application and return to the PGM window.'     #14 @13 '- Exit from the SAS System.'     #19 @10 'You must have the menus turned on.'; 

The DISPLAY statement displays the window HRSELECT.

 display hrselect;  run; 

Primary window, HRSELECT.

click to expand

Using a Data Entry Program

When the user selects Data_Entry from the menu bar in the HRSELECT window, a pull-down menu is displayed. When the user selects one of the listed departments or chooses to enter a different department, the following statements are invoked. These statements are stored in the file that is referenced by the DE fileref.

The WINDOW statement creates the HRDATA window. MENU= associates the PROCLIB.MENUS.ENTRDATA.PMENU entry with the window.

 data proclib.deptxx;      window hrdata menu=proclib.menus.entrdata      #5  @10 'Employee Number'      #8  @10 'Salary'      #11 @10 'Employee Name'      #5  @31 empno .      #8  @31 salary 10.      #11 @31 name .      #19 @10 'Press ENTER to add the observation to the data set.'; 

The DISPLAY statement displays the HRDATA window.

 display hrdata;  run; 

The %INCLUDE statement recalls the statements in the file HRWDW. The statements in HRWDW redisplay the primary window. See the HRSELECT window on page 714.

 filename hrwdw '  external-file  ';  %include hrwdw;  run; 

The SELECTION and DIALOG statements in the PROC PMENU step modify the DATA statement in this program so that the correct department name is used when the data set is created. That is, if the user selects Other Departments and enters DEPT05 , then the DATA statement is changed by the command string in the DIALOG statement to

 data proclib.dept05; 

Data entry window, HRDATA.

click to expand

Printing a Program

When the user selects Print_Report from the menu bar, a pull-down menu is displayed. When the user selects one of the listed departments or chooses to enter a different department, the following statements are invoked. These statements are stored in the external file referenced by the PRT fileref.

PROC PRINTTO routes the output to an external file.

 proc printto file='  external-file  ' new;  run; 

The xx s are changed to the appropriate department number by the CHANGE command in the SELECTION or DIALOG statement in the PROC PMENU step. PROC PRINT prints that data set.

 libname proclib '  SAS-data-library  ';  proc print data=proclib.deptxx;     title 'Information for deptxx';  run; 

This PROC PRINTTO steps restores the default output destination. See Chapter 36, The PRINTTO Procedure, on page 787 for documentation on PROC PRINTTO.

 proc printto;  run; 

The %INCLUDE statement recalls the statements in the file HRWDW. The statements in HRWDW redisplay the primary window.

 filename hrwdw '  external-file  ';  %include hrwdw;  run; 

Example 5: Associating Menus with a FRAME Application

Procedure features:

  • ITEM statement

    MENU statement

Other features: SAS/AF software

This example creates menus for a FRAME entry and gives the steps necessary to associate the menus with a FRAME entry from SAS/AF software.

Program

Declare the PROCLIB library. The PROCLIB library is used to store menu definitions.

 libname proclib '  SAS-data-library  '; 

Specify the catalog for storing menu definitions. Menu definitions will be stored in the PROCLIB.MENUCAT catalog.

 proc pmenu catalog=proclib.menucat; 

Specify the name of the catalog entry. The MENU statement specifies FRAME as the name of the catalog entry. The menus are stored in the catalog entry PROCLIB.MENUS.FRAME.PMENU.

 menu frame; 

Design the menu bar. The ITEM statements specify the items in the menu bar. The value of MENU= corresponds to a subsequent MENU statement.

 item 'File' menu=f;  item 'Help' menu=h; 

Design the File menu. The MENU statement equates to the MENU= option in a preceding ITEM statement. The ITEM statements specify the selections that are available under File on the menu bar.

 menu f;     item 'Cancel';     item 'End'; 

Design the Help menu. The MENU statement equates to the MENU= option in a preceding ITEM statement. The ITEM statements specify the selections that are available under Help on the menu bar. The value of the SELECTION= option equates to a subsequent SELECTION statement.

 menu h;     item 'About the application' selection=a;     item 'About the keys'   selection=k; 

Specify commands for the Help menu. The SETHELP command specifies a HELP entry that contains user-written information for this application. The semicolon that appears after the HELP entry name enables the HELP command to be included in the string. The HELP command invokes the HELP entry.

 selection a 'sethelp proclib.menucat.app.help;help';             selection k 'sethelp proclib.menucat.keys.help;help';  run;  quit; 

Steps to Associate Menus with a FRAME

  1. In the BUILD environment for the FRAME entry, from the menu bar, select View Properties Window

  2. In the Properties window, select the Value field for the pmenuEntry Attribute Name. The Select An Entry window opens.

  3. In the Select An Entry window, enter the name of the catalog entry that is specified in the PROC PMENU step that creates the menus.

  4. Test the FRAME as follows from the menu bar of the FRAME: Build Test

Notice that the menus are now associated with the FRAME.

click to expand

Refer to Getting Started with the FRAME Entry: Developing Object-Oriented Applications for more information on SAS programming with FRAME entries.




Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net