The SAS Output Delivery System and reporting techniques

ODS PDF startpage=no - Preventing PROC REPORT from starting on a new page

Accepted Solution Solved
Reply
Super Contributor
Posts: 387
Accepted Solution

ODS PDF startpage=no - Preventing PROC REPORT from starting on a new page

Hi,

SAS 9.2 on Windows

Submit this code:

filename temp temp;

options orientation=portrait nodate nonumber spool;

ods _all_ close;

ods escapechar = '^';

ods pdf file=temp notoc startpage=no style=SeasidePrinter;

title;

footnote;

proc report data=sashelp.class nowd;

  where name =: "A";

  columns sex age name height weight;

  define sex    / order;

  define age    / order;

  define name   / display;

  define height / analysis;

  define weight / analysis;

quit;

proc report data=sashelp.shoes nowd;

quit;

ods pdf close;

ods listing;

Is there a way I can prevent sashelp.shoes from starting on a new page?

In my "real report", the proc report sashelp.class code is a page header, displaying the parameters for the report.  It looks a bit weird to see the report header page, a blank data portion, then the data portion begins on a second page (without a header).

What would be really cool is for the page header to print on each page of a multi page output.  IOW, sashelp.class would print at the top of each page of the sashelp.shoes output.  AFAIK, I could probably get this to work using the ODS Data Step Interface, but at this point in my project that would involve too much of a re-write.

Thanks,

Scott


Accepted Solutions
Solution
‎06-01-2012 08:05 AM
Respected Advisor
Posts: 3,799

Re: ODS PDF startpage=no - Preventing PROC REPORT from starting on a new page

Posted in reply to ScottBass

If you do your own summary I believe you can get pretty much everything you want.  Including no TOTAL row when N=1.

filename temp temp;

options orientation=portrait nodate nonumber spool;

ods _all_ close;

ods escapechar = '^';

ods pdf file=temp notoc startpage=no style=SeasidePrinter;

title;

footnote;

proc report data=sashelp.class nowd;

  where name =: "A";

  columns sex age name height weight;

  define sex    / order;

  define age    / order;

  define name   / display;

  define height / analysis;

  define weight / analysis;

quit;

proc summary data=sashelp.shoes missing chartype;

   class region subsidiary product;

   types region region*subsidiary region*subsidiary*product;

   var sales;

   output out=sum sum=;

   run;

data sum;

   set sum;

   if _type_ eq '110' and _freq_ eq 1 then delete;

   subsidiary = coalesceC(subsidiary,'ff'x);

   product    = coalesceC(product,'ff'x);

   run;

proc format;

   value $fftot(default=64) 'ff'x='Total';

   run;

proc sort data=sum;

   by region subsidiary product;

   run;

proc report data=sum(obs=49) nowd spanrows missing;

   columns region subsidiary product sales;

   define region           / order order=interna;

   define subsidiary       / order order=internal format=$fftot.;

   define product          / order order=internal format=$fftot.;

   define sales            / analysis;

   run;  

proc report data=sum(firstobs=50) nowd spanrows missing;

   columns region subsidiary product sales;

   define region           / order ;

   define subsidiary       / order order=internal format=$fftot.;

   define product          / order order=internal format=$fftot.;

   define sales            / analysis;

   run;  

ods pdf close;

ods listing;

View solution in original post


All Replies
Respected Advisor
Posts: 3,799

Re: ODS PDF startpage=no - Preventing PROC REPORT from starting on a new page

Posted in reply to ScottBass

Not an answer but if you print a subset of obs from SHOES to fit on the page it will be on the same page as CLASS.

Something like this might work for you.

proc report data=sashelp.shoes(obs=20) nowd;

   run;

proc report data=sashelp.shoes(firstobs=21) nowd;

   run;

Super Contributor
Posts: 387

Re: ODS PDF startpage=no - Preventing PROC REPORT from starting on a new page

Posted in reply to data_null__

Hi Data,

Sorry, I oversimplified my example.  My "real" report looks more like:

proc report data=sashelp.class nowd;

  where name =: "A";

  columns sex age name height weight;

  define sex    / order;

  define age    / order;

  define name   / display;

  define height / analysis;

  define weight / analysis;

quit;

proc report data=sashelp.shoes nowd spanrows;

  columns region subsidiary product sales;

  define region           / order;

  define subsidiary       / order;

  define product          / display;

  define sales            / analysis;

  break after region / summarize;

  break after subsidiary / summarize;

  compute after region;

    call missing(subsidiary,product);

  region="Total";

  endcomp;

  compute after subsidiary;

    call missing(region,subsidiary);

  product="Total";

  endcomp;

quit;

The obs/firstobs approach causes a partial subtotal to appear on the first page, then a partial subtotal on the final page, which the end user will find confusing.

Great idea - apologies my example code was oversimplified.

Regards,

Scott

P.S.: Thanks for the tip for SPANROWS in the other thread.  The break after and compute after code messes that up slightly, but it's still closer to what the end user wants.

Solution
‎06-01-2012 08:05 AM
Respected Advisor
Posts: 3,799

Re: ODS PDF startpage=no - Preventing PROC REPORT from starting on a new page

Posted in reply to ScottBass

If you do your own summary I believe you can get pretty much everything you want.  Including no TOTAL row when N=1.

filename temp temp;

options orientation=portrait nodate nonumber spool;

ods _all_ close;

ods escapechar = '^';

ods pdf file=temp notoc startpage=no style=SeasidePrinter;

title;

footnote;

proc report data=sashelp.class nowd;

  where name =: "A";

  columns sex age name height weight;

  define sex    / order;

  define age    / order;

  define name   / display;

  define height / analysis;

  define weight / analysis;

quit;

proc summary data=sashelp.shoes missing chartype;

   class region subsidiary product;

   types region region*subsidiary region*subsidiary*product;

   var sales;

   output out=sum sum=;

   run;

data sum;

   set sum;

   if _type_ eq '110' and _freq_ eq 1 then delete;

   subsidiary = coalesceC(subsidiary,'ff'x);

   product    = coalesceC(product,'ff'x);

   run;

proc format;

   value $fftot(default=64) 'ff'x='Total';

   run;

proc sort data=sum;

   by region subsidiary product;

   run;

proc report data=sum(obs=49) nowd spanrows missing;

   columns region subsidiary product sales;

   define region           / order order=interna;

   define subsidiary       / order order=internal format=$fftot.;

   define product          / order order=internal format=$fftot.;

   define sales            / analysis;

   run;  

proc report data=sum(firstobs=50) nowd spanrows missing;

   columns region subsidiary product sales;

   define region           / order ;

   define subsidiary       / order order=internal format=$fftot.;

   define product          / order order=internal format=$fftot.;

   define sales            / analysis;

   run;  

ods pdf close;

ods listing;

Super Contributor
Posts: 387

Re: ODS PDF startpage=no - Preventing PROC REPORT from starting on a new page

Posted in reply to data_null__

Hi Data,

I'm always amazed, not only at your actual SAS code, but at your thought process on how you approach a problem.  You usually come up with ways that make me go "D'oh" after I see them, but somehow escaped me until after your post.

Keep learning SAS ;-)

Thanks,

Scott

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1544 views
  • 3 likes
  • 2 in conversation