Previous Page | Next Page

The PMENU Procedure

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


Program

 Note about code
libname proclib 'SAS-data-library';
 Note about code
filename de     'external-file';
filename prt    'external-file';
 Note about code
 proc pmenu catalog=proclib.menus;
 Note about code
    menu select;
 Note about code
   item 'File' menu=f;
   item 'Data_Entry' menu=deptsde;
   item 'Print_Report' menu=deptsprt;
 Note about code
   menu f;
      item 'End this window' selection=endwdw;
      item 'End this SAS session' selection=endsas;
      selection endwdw 'end';
      selection endsas 'bye';
 Note about code
    menu deptsde;
       item 'For Dept01' selection=de1;
       item 'For Dept02' selection=de2;
       item 'Other Departments' dialog=deother;
 Note about code
       selection de1 'end;pgm;include de;change xx 01;submit';
       selection de2 'end;pgm;include de;change xx 02;submit';
 Note about code
       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;
 Note about code
      menu deptsprt;
         item 'For Dept01' selection=prt1;
         item 'For Dept02' selection=prt2;
         item 'Other Departments' dialog=prother;
 Note about code
         selection prt1 
               'end;pgm;include prt;change xx 01 all;submit';
         selection prt2 
               'end;pgm;include prt;change xx 02 all;submit';
 Note about code
      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;
 Note about code
   run;
 Note about code
     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:

 Note about code
   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.';
 Note about code
      display hrselect;
   run;
 Note about figure

[HRSELECT Window]


Using a Data Entry Program

When the user selects Data_Entry from the menu bar in the HRSELECT window, a 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.

 Note about code
  data proclib.deptxx;
      window hrdata menu=proclib.menus.entrdata
      #5  @10 'Employee Number'
      #8  @10 'Salary'
      #11 @10 'Employee Name'
      #5  @31 empno $4.
      #8  @31 salary 10.
      #11 @31 name $30.
      #19 @10 'Press ENTER to add the observation to the data set.';
 Note about code
      display hrdata;
  run;
 Note about code
  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;

 Note about figure

[HRDATA Window]


Printing a Program

When the user selects Print_Report from the menu bar, a 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.

 Note about code
   proc printto file='external-file' new;
   run;
 Note about code
   libname proclib 'SAS-data-library';

   proc print data=proclib.deptxx;
      title 'Information for deptxx';
   run;
 Note about code
   proc printto;
   run;
 Note about code
   filename hrwdw 'external-file';
   %include hrwdw;
   run;

Previous Page | Next Page | Top of Page