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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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