BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ChrisNZ
Tourmaline | Level 20

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;

kk .png

ChrisNZ
Tourmaline | Level 20

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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 8027 views
  • 8 likes
  • 4 in conversation