The SAS Output Delivery System and reporting techniques

Proc Report By variable and new page in ODS PDF

Accepted Solution Solved
Reply
Contributor
Posts: 26
Accepted Solution

Proc Report By variable and new page in ODS PDF

Hello.  I have the below Proc Report I have run, with a By group.  When I output to ODS PDF I would like each By group to be on its own page as opposed to 1 report which runs over the page.  Is it possible to do this?  The reason all the variables are DISPLAY is because of how I had to set this up.  Basically this is the final output from 4 different Proc Reports stacked on top of each other.  Thank you.

 

ODS PDF STARTPAGE=NOW;

ODS LAYOUT gridded rows=1 columns=1 STYLE={backgroundcolor=white};

ODS REGION ;

ods proclabel "Outflow Summary";

PROC REPORT DATA=WORK.OUTFLOWS_TOTALA style(HEADER)=[background=blue foreground=white font_weight=bold] CONTENTS='';

BY Metric NOTSORTED;

COLUMN ('Total FM Outflow Summary' Metric Lvl2_FF_Region SOURCE MTD PrevDay PrevWk PrevMo PrevMo2 PrevMo3);

DEFINE Metric / group style=[font_weight=bold];

DEFINE Lvl2_FF_Region / group;

DEFINE Source / DISPLAY;

DEFINE MTD / DISPLAY FORMAT=COMMA8.;

DEFINE PrevDay / DISPLAY "&PREVDAY" FORMAT=COMMA8.;

DEFINE PrevWk / DISPLAY "&PREVWKE" FORMAT=COMMA8.;

DEFINE PrevMo / DISPLAY "&PREVMOE" FORMAT=COMMA8.;

DEFINE PrevMo2 / DISPLAY "&PREVMOE2" FORMAT=COMMA8.;

DEFINE PrevMo3 / DISPLAY "&PREVMOE3" FORMAT=COMMA8.;

COMPUTE Source;

if SOURCE='' then call define (_row_,'style','style=[background=lightgrey font_weight=bold]');

ENDCOMP;

BREAK BEFORE Metric / CONTENTS='' page;

RUN;

ODS LAYOUT END;

ODS PDF CLOSE;


Accepted Solutions
Solution
‎04-22-2016 09:20 AM
Esteemed Advisor
Esteemed Advisor
Posts: 6,721

Re: Proc Report By variable and new page in ODS PDF

Can't read as all upper case and no indentation.  From your initial text I would suggest:

...
  by <variable>;

  break after <variable> / page;

However why have the data in both by group and in a column, doesn't make much sense.  If you need it in the body then put it there, drop the by bit and do a break after <variable> / page and have a subheading or compute block display the by group.

...
  break after <variable> / page;
  compute before;
    line <variable>;
  endcomp;

View solution in original post


All Replies
Solution
‎04-22-2016 09:20 AM
Esteemed Advisor
Esteemed Advisor
Posts: 6,721

Re: Proc Report By variable and new page in ODS PDF

Can't read as all upper case and no indentation.  From your initial text I would suggest:

...
  by <variable>;

  break after <variable> / page;

However why have the data in both by group and in a column, doesn't make much sense.  If you need it in the body then put it there, drop the by bit and do a break after <variable> / page and have a subheading or compute block display the by group.

...
  break after <variable> / page;
  compute before;
    line <variable>;
  endcomp;
Contributor
Posts: 26

Re: Proc Report By variable and new page in ODS PDF

Thank you I am new to using Proc Report so I appreciate your insights. 

Esteemed Advisor
Esteemed Advisor
Posts: 6,721

Re: Proc Report By variable and new page in ODS PDF

One thing to add, by subheading I mean:

...
  by <variable>;
  title3 "This is for data #byval1";
  break after <variable> / page;
  

The title can have by values in them, so you can use the column as data, and pass it to a title statement.

Contributor
Posts: 26

Re: Proc Report By variable and new page in ODS PDF

Fantastic, thank you again. Greatly appreciated!!
Post a Question
Discussion Stats
  • 4 replies
  • 449 views
  • 1 like
  • 2 in conversation