Features: |
DIALOG statement : SAS macro invocation ITEM statement : DIALOG= option RADIOBOX statement option: DEFAULT= RBUTTON statement option: SUBSTITUTE= |
Other features: |
SAS macro invocation |
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 '%%wbuild(%1,%2,@1,%3)';
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';
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';
text #13 @1 'Enter Value for Search:'; text #13 @25 len=6;
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;
item 'File' menu=f; item 'Edit' menu=e; item 'Scroll' menu=s; item 'Subset' menu=sub; item 'Help' menu=h;
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 s; item 'Next Obs' selection=n; item 'Prev Obs' selection=p; item 'Top'; item 'Bottom'; selection n 'forward'; selection p 'backward';
menu h; item 'Keys'; item 'About this application' selection=hlp; selection hlp 'sethelp proclib.menucat.staffhlp.help;help';
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';
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';
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
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.
&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
OR
between the
individual clauses. The next part of the WHERE command becomes OR
pol_a2 GE .50
%macro wbuild(region,prefix,numvar,value,operator); /* check to see if value is present */ %if &value ne %then %do; where region="®ion" 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;