DATA Step, Macro, Functions and more

ods output

Reply
Frequent Contributor
Posts: 90

ods output

 

 I want to get below output in one page. I used two "proc report" in one output. How can I modify my code and use one "proc report" to get the same result? Thanks

 

 

1.JPG

Below is my code.

 

 

data a;
format patid x1-x10 y1-y10 $8.;
input patid x1-x10 y1-y10;
datalines;
001 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 b1 b2 b3 b4 b5 b5 b5 b8 b9 b10
001 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 b1 b2 b3 b4 b5 b5 b5 b8 b9 b10
001 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 b1 b2 b3 b4 b5 b5 b5 b8 b9 b10
002 aa1 aa2 aa3 aa4 aa5 aa6 aa7 aa8 aa9 aa10 bb1 bb2 bb3 bb4 bb5 bb6 bb7 bb8 bb9 bb10
002 aa1 aa2 aa3 aa4 aa5 aa6 aa7 aa8 aa9 aa10 bb1 bb2 bb3 bb4 bb5 bb6 bb7 bb8 bb9 bb10
002 aa1 aa2 aa3 aa4 aa5 aa6 aa7 aa8 aa9 aa10 bb1 bb2 bb3 bb4 bb5 bb6 bb7 bb8 bb9 bb10
002 aa1 aa2 aa3 aa4 aa5 aa6 aa7 aa8 aa9 aa10 bb1 bb2 bb3 bb4 bb5 bb6 bb7 bb8 bb9 bb10
002 aa1 aa2 aa3 aa4 aa5 aa6 aa7 aa8 aa9 aa10 bb1 bb2 bb3 bb4 bb5 bb6 bb7 bb8 bb9 bb10
;

ods rtf file="C:\XXXXXX\1.rtf" startpage=no;
proc report data=a;
column patid x1-x10;
define patid / id;
run;

proc report data=a;
column patid y1-y10;
define patid / id;
run;
ods rtf close;

Super User
Posts: 11,343

Re: ods output

Posted in reply to Niugg2010

Since proc report is going to want the same columns displayed in all tables then I don't thin one proc report, or tabulate or print for that matter will work with your existing data.

 

You could add a group variable to use for BY Group processing and assign the y variables to X variable names.

Something like this (untested)

data need;
   set a;
   array xval x: ;
   array yval y: ;
   group=1;
   output;
   group=2;
   do i= 1 to dim(x);
      xval[i]=yval[i];
   end;
   output;
   keep group x: ;
run;
proc sort data=need; 
   by group;
run;

proc report data=a;
by group;
column patid x1-x10;
define patid / id;
run;
Super User
Posts: 19,860

Re: ods output

Posted in reply to Niugg2010

I'm guessing this is because the table is too wide to fit otherwise? 

 

Unfortunately manual control is your best bet to get it to align the way you want. 

Frequent Contributor
Posts: 90

Re: ods output

Thanks.

Super User
Super User
Posts: 7,076

Re: ods output

Posted in reply to Niugg2010

This seems to work.

ods rtf file="C:\downloads\2.rtf" startpage=no;

proc report data=a;
  column patid x1-x10 patid=patid2 y1-y10;
  define patid2 / page ;
run;

ods rtf close;
Valued Guide
Posts: 634

Re: ods output

The ODS LAYOUT has matured quite a bit and gives you some additional flexibility to put multiple output objects on a single page.
Frequent Contributor
Posts: 90

Re: ods output

Yes. It works. 

Ask a Question
Discussion stats
  • 6 replies
  • 211 views
  • 2 likes
  • 5 in conversation