SAS Programming

DATA Step, Macro, Functions and more
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

 

 

undefined

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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1562 views
  • 2 likes
  • 5 in conversation