Referencing BY Group Values Within Titles
When using 'by group' processing to output reports, the #byval function can be used to include the name of the 'by group' within the title.
In order to include the value on a report use the #byval function followed by the group variable to be displayed. Note that the nobyline option must be present in order to display the correct titles.
proc sort data=sashelp.class out=work.class; by sex; run;
proc print data=work.class noobs; var name sex age; by sex; title "These people have a gender of #byval(sex)"; run;
Producing the following results:
These people have a gender of F Name Sex Age Alice F 13 Barbara F 13 Carol F 14 Jane F 12 Janet F 15 Joyce F 11 Judy F 14 Louise F 12 Mary F 15
These people have a gender of M Name Sex Age Alfred M 14 Henry M 14 James M 12 Jeffrey M 13 John M 12 Philip M 16 Robert M 12 Ronald M 15 Thomas M 11 William M 15