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 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.
| libname proclib 'SAS-data-library';
filename de 'external-file';
filename prt 'external-file';
|
| proc pmenu catalog=proclib.menus; |
| menu select;
|
| item 'File' menu=f;
item 'Data_Entry' menu=deptsde;
item 'Print_Report' menu=deptsprt; |
| menu f;
item 'End this window' selection=endwdw;
item 'End this SAS session' selection=endsas;
selection endwdw 'end';
selection endsas 'bye'; |
| menu deptsde;
item 'For Dept01' selection=de1;
item 'For Dept02' selection=de2;
item 'Other Departments' dialog=deother;
|
| selection de1 'end;pgm;include de;change xx 01;submit';
selection de2 'end;pgm;include de;change xx 02;submit';
|
| 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;
|
| menu deptsprt;
item 'For Dept01' selection=prt1;
item 'For Dept02' selection=prt2;
item 'Other Departments' dialog=prother;
|
| selection prt1
'end;pgm;include prt;change xx 01 all;submit';
selection prt2
'end;pgm;include prt;change xx 02 all;submit';
|
| 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;
|
| run;
|
| 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; |
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:
| 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.'; |
| display hrselect;
run; |
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.
| 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.'; |
| display hrdata;
run; |
| 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
, the DATA statement is changed by the command string on the
DIALOG statement to
data proclib.dept05;
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 file='external-file' new;
run; |
| libname proclib 'SAS-data-library';
proc print data=proclib.deptxx;
title 'Information for deptxx';
run; |
| proc printto;
run; |
| filename hrwdw 'external-file';
%include hrwdw;
run; |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.