PMENU Procedure

Example 2: Collecting User Input in a Dialog Box

Features:

DIALOG statement

TEXT statement option: LEN=

Details

This example adds a dialog box to the menus created in Building a Menu Bar for an FSEDIT Application. The dialog box enables the user to use a WHERE clause to subset the SAS data set.
Tasks include these:
  • collecting user input in a dialog box
  • creating customized menus for an FSEDIT application

Program

libname proclib
'SAS-data-library';
proc pmenu catalog=proclib.menucat;
   menu project;
      item 'File' menu=f;
      item 'Edit' menu=e;
      item 'Scroll' menu=s;
      item 'Subset' menu=sub;
      item 'Help' menu=h;
      menu f;
         item 'Goback' selection=g;
         item 'Save';
         selection g 'end';
      menu e;
         item 'Cancel';
         item 'Add';
      menu s;
         item 'Next Obs' selection=n;
         item 'Prev Obs' selection=p;
         item 'Top';
         item 'Bottom';
         selection n 'forward';
         selection p 'backward';
      menu sub;
         item 'Where' dialog=d1;
         item 'Where Clear';
      menu h;
         item 'Keys';
         item 'About this application' selection=hlp;
         selection hlp 'sethelp proclib.menucat.staffhlp.help;help';
      dialog d1 'where @1';
         text #2 @3 'Enter a valid WHERE clause or UNDO';
         text #4 @3 'WHERE ';
         text #4 @10 len=40;
quit;

Program Description

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(R) Component Language 9.3: Reference for complete documentation on SCL.
For other methods of associating the customized menu bar with the FSEDIT window, see Associating a Menu Bar with an FSEDIT Session.
The following dialog box appears when the user chooses Subset and then Where.
Where Dialog Box