The SAS Output Delivery System and reporting techniques

Print two data set in the same output page

Reply
New Contributor
Posts: 4

Print two data set in the same output page

Hello,

I am developing a SAS macro.

The macro output have two result datasets. For some reasons I want to keep them separately. Is there anyway to print both datasets in the same output page? Because if I call proc print twice, result datasets will be printed in 2 separate page even thought they have only a few rows.

Thanks a lot.

Grand Advisor
Posts: 10,241

Re: Print two data set in the same output page

Can you provide some example of what you want the output to look like and which output destination you are using?

If you use ODS RTF with the KEEPN and STARTPAGE=NO options the output might fit on one page. You might want to investigate using a different style than the default RTF style to one with a smaller font to help.

Respected Advisor
Posts: 5,001

Re: Print two data set in the same output page

You could go really old style and use PUT statements to write your report.

data _null_;

  file print header=pagetop;

  if not eof1 then do;

     set dataset1 end=eof1;

     put some stuff on the left hand side of the page @;

  end;

  if not eof2 then do;

     set dataset2 end=eof2;

     put some stuff on the right hand side of the page;

  end;

  return;

  pagetop:

  * Add top-of-page titles/headings, etc.;

  return;

run;

Its hard work, but extremely flexible.

Grand Advisor
Posts: 9,596

Re: Print two data set in the same output page

If you need put them together in a page vertically , add ods option   startpage=never ,

or if you want side by side.

Then You need some advanced skill of ODS.

Code is take from a SAS book of Arthur.Carpenter

ods listing close;
ods pdf style=sasweb file="c:\temp\x.pdf";
ods layout start;


ods region x=.5in y=.1in width=3in height=4in; 
proc report data=sashelp.prdsale(where=(prodtype='OFFICE')) nowd;
run;
ods region x=5in y=.1in width=3in height=4in;
proc report data=sashelp.prdsale(where=(prodtype='FURNITURE')) nowd;
run;
ods layout end;
ods pdf close;
ods listing;

Xia Keshan

Message was edited by: xia keshan

New Contributor
Posts: 4

Re: Print two data set in the same output page

Thank you very much for your replies.

I will try the put statement option first since it looks more friendly to me.

Grand Advisor
Posts: 10,241

Re: Print two data set in the same output page

If one above the other is acceptable the ODS solution will be much friendlier and easier to maintain.

Also what you want to view this in makes a difference.

New Contributor
Posts: 4

Re: Print two data set in the same output page

I have 2 output datasets which have around 10 rows and want to put them in the same SAS output page vertically. Could you give me a bit more detail about ODS solution.

Thanks a lot.

Grand Advisor
Posts: 10,241

Re: Print two data set in the same output page

basic code for RTF (Word) output would be:

ods rtf file="c:\myfolder\mydocument.rtf" startpage=no;

proc print data=dataset1;

run;

proc print data=dataset2;

run;

ods rtf close;

There are lots of options involved in the ODS RTF statement that relate to style, table of contents and how titles appear. If you want separate titles for you two data sets you will  likely want the option Bodytitle on the ODS RTF statement.

Occasional Contributor
Posts: 18

Re: Print two data set in the same output page

What about appending them to each other in a temporary dataset for the sake of printing?

data temp;

     set dataset1 dataset2;

run;

proc print data=temp;

run;

Ask a Question
Discussion stats
  • 8 replies
  • 2010 views
  • 0 likes
  • 5 in conversation