BookmarkSubscribeRSS Feed
ThanhUSF
Calcite | Level 5

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.

8 REPLIES 8
ballardw
Super User

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.

Astounding
PROC Star

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.

Ksharp
Super User

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

ThanhUSF
Calcite | Level 5

Thank you very much for your replies.

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

ballardw
Super User

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.

ThanhUSF
Calcite | Level 5

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.

ballardw
Super User

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.

JohnW_
Calcite | Level 5

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 7849 views
  • 2 likes
  • 5 in conversation