BookmarkSubscribeRSS Feed
Niugg2010
Obsidian | Level 7

 

 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;

6 REPLIES 6
ballardw
Super User

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;
Reeza
Super User

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. 

Niugg2010
Obsidian | Level 7

Thanks.

Tom
Super User Tom
Super User

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;
ArtC
Rhodochrosite | Level 12
The ODS LAYOUT has matured quite a bit and gives you some additional flexibility to put multiple output objects on a single page.
Niugg2010
Obsidian | Level 7

Yes. It works. 

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