After a bit of twisting the arm of http://support.sas.com/kb/31/278.html, here is a solution.
It sucks howewer.
Why SETLABEL doesn't work, and why we have to create a new variable and use a bunch of options specific to PROC REPORT when this should be managed within PROC DOCUMENT is a mystery.
No such messing about with PROC GPLOT for eg.
data TEST;
set SASHELP.CLASS;
COUNT=1;
run;
ods document name=WORK.TEST(write);
ods proclabel="Class"; * set level 1 label ;
proc report nowd data=TEST contents=""; * set level 2 label (i.e. no level2);
where WEIGHT < 95;
col COUNT NAME AGE HEIGHT WEIGHT;
define COUNT / group noprint;
break before COUNT / contents="Weight < 95" page; * set level 3 label;
run;
proc report nowd data=test contents=""; * set level 2 label;
where WEIGHT >= 95;
col COUNT NAME AGE HEIGHT WEIGHT;
define COUNT / group noprint;
break before COUNT / contents="Weight >= 95" page; * set level 3 label;
run;
%sysfunc(ifc(%sysfunc(cexist(WORK.GSEG.PLOTA.GRSEG))
,%str(proc catalog c=GSEG; delete PLOTA.GRSEG; quit; )
,));
proc gplot data=SASHELP.CLASS;
plot HEIGHT*WEIGHT / name='plotA';
run;
quit;
ods document close;
proc document name=WORK.TEST;
list /levels=all;run;
move \Report#2\Report#1 to \Report#1;
setlabel \Gplot#1\PLOTA#1 'H vs W plot';
move \Gplot#1\PLOTA#1 to \Report#1;
ods pdf file="test2.pdf";
replay \Report#1 ; run;
ods pdf close;
quit;
Digressing slightly, but just out of interest, SETLABEL also works fine for data steps and overwrites the objectlabel label option (which also works fine) if it is set.
data TEST;
set SASHELP.CLASS;
COUNT=1;
run;
ods document name=WORK.TEST(write);
ods proclabel="Class"; * set level 1 label ;
proc report nowd data=TEST contents="";* set level2 label (i.e. no level2);
where WEIGHT < 95;
col COUNT NAME AGE HEIGHT WEIGHT;
define COUNT / group noprint;
break before COUNT / contents="Weight < 95" page; * set level 3 label;
run;
proc report nowd data=test contents=""; * set level 2 label;
where WEIGHT >= 95;
col COUNT NAME AGE HEIGHT WEIGHT;
define COUNT / group noprint;
break before COUNT / contents="Weight >= 95" page; * set level 3 label;
run;
%sysfunc(ifc(%sysfunc(cexist(WORK.GSEG.PLOTA.GRSEG))
,%str(proc catalog c=GSEG; delete PLOTA.GRSEG; quit; )
,));
proc gplot data=SASHELP.CLASS;
plot HEIGHT*WEIGHT / name='plotA';
run;
quit;
data _null_;
file print ods=(objectlabel='DS'); * this label works;
set sashelp.class;
put _ods_;
run;
ods document close;
ods listing close;
proc document name=WORK.TEST;
ods listing;
list /levels=all;run;
ods listing close;
move \Report#2\Report#1 to \Report#1;
setlabel \Gplot#1\PLOTA#1 'H vs W plot';
move \Gplot#1\PLOTA#1 to \Report#1;
setlabel \Datastep#1\FilePrint5#1 'DS2'; * this label works too;
move \Datastep#1\FilePrint5#1 to \Report#1;
ods pdf file="test2.pdf";
replay \Report#1 ; run;
ods pdf close;
quit;
One thing I can't seem to be able to control the name of the data step output. The number in FilePrint5 increments all the time.
\Datastep#1\FilePrint5#1
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.