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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 7520 views
  • 8 likes
  • 4 in conversation