Collate 2 ODS Reports and Output to 1 File

Reply
Occasional Contributor
Posts: 6

Collate 2 ODS Reports and Output to 1 File

Is it possible to combine (collate) 2 ODS reports and output to 1 pdf instead of 2?

I have a summary and a detail report and want to collate and print to 1 file so end user doesn't need to collate.  It will be a one-to-many as 1 summary sheet for many detail reports.

Super User
Posts: 19,772

Re: Collate 2 ODS Reports and Output to 1 File

Posted in reply to persephone3

What type of ODS is your original? Do you have Adobe Professional?

I've used SAS to write a VB Script to combine files , but Adobe Professional has a fairly good automation tool as well.

You can also look at Proc Document to control when the outputs are displayed to get the files the way you want them.

Occasional Contributor
Posts: 6

Re: Collate 2 ODS Reports and Output to 1 File

I am outputting both to pdf. and do not have Adobe Professional.  I'll take a look at proc document.  Thank you.

Super User
Posts: 11,343

Re: Collate 2 ODS Reports and Output to 1 File

Posted in reply to persephone3

Or it may just take a minor adjustment to your work flow. After you have the data ready put all of the output generating code within one ODS output "sandwich".

ods pdf file="mypdffile.pdf";

<first output procedure>

<second output procedure>

...

<last output procedure>

ods pdf close;

Occasional Contributor
Posts: 6

Re: Collate 2 ODS Reports and Output to 1 File

This is what I need to do, but getting the 'data ready' is my problem.  One Summary Report (formatted in ODS) needs to PRECEDE each group of Detail Reports (formatted in ODS).  The summary and detail reports are separate SAS datasets.

Super User
Posts: 11,343

Re: Collate 2 ODS Reports and Output to 1 File

Posted in reply to persephone3

No problem. Just put the code to create each report in order. Could look like below. The datasets should be available to you as supplied by SAS for examples.

ods pdf file "mypdffile.pdf";

Proc means data=sashelp.class mean stddev;

class sex;

var height weight;

title 'Summary of Height and Weight by Sex';

run;

proc print data=sashelp.class noobs label;

     title 'Heights and weights details';

     var name sex height weight;

run;

proc tabulate data=sashelp.cars;

     class make;

     class type;

     var horsepower;

     table make, type*horsepower*mean;

     title 'Average horsepower by make and type';

run;

proc print data=sashelp.cars noobs label;

     title 'Detail Horsepower by Make and Car Type';

     var make type horsepower;

run;

title;

ods pdf close;

Occasional Contributor
Posts: 6

Re: Collate 2 ODS Reports and Output to 1 File

Great example Thanks!  I am almost there.  I will use the 'Horsepower by Make and Type' datasets to further explain.

I want to print groupings by Make summary then Make detail.  So print the summary for Acura then the detail for Acura and continue to eof for all Makes.  I tried building in 'do while' but it was unsuccessful.

Thanks again!

Super User
Posts: 19,772

Re: Collate 2 ODS Reports and Output to 1 File

Posted in reply to persephone3

You can do it via macro's if you want, how familiar are you with macro code? Is efficiency a concern, because this isn't very efficient.

Ask a Question
Discussion stats
  • 7 replies
  • 218 views
  • 3 likes
  • 3 in conversation