BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi

I'm working on a report with approx. 18 variables... too much to fit on a single A4-page as it is.
I would like to split each observation into two lines for output. I'm using PROC PRINT for printing.

The following is a example of what I wish to achieve. Please excuse the lack of proper formatting.

Original table
Obs Var1 Var2 Var3 ... Var18
1 a b c ... r
2 aa bb cc ... rr

Split table
Obs Var1 Var2 Var3 ... Var9
Var 10 Var11 Var12 ... Var18
1 a b c ... i
1 j k l ... r
2 aa bb cc ... ii
2 jj kk ll ... rr

Is there a simple way to do this?

Best regards,
Thomas
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
You might want to take a look at this previous forum posting on dealing with very wide tables:
http://support.sas.com/forums/thread.jspa?messageID=414ƞ

The fact is that splitting the table the way you want is not automatic with ODS destinations.

What you would have to do, if you can't tweak the fonts and cellpadding, etc to make the information fit is to write a program to "split" the data....as shown in the program below.

cynthia
[pre]
data newclass;
set sashelp.class;
** might have to control length for character variables;
** explicitly if you have differing lengths;
length row $5;
obsno = _n_;
row = put(_n_,z2.0)||'-01';
var1 = name;
var2 = age;
var3 = height;
output;
row = put(_n_,z2.0)||'-02';
var1 = sex;
var2 = .;
var3 = weight;
output;
run;

options missing = ' ';
ods listing close;
ods pdf file='splitrow.pdf';
proc report data=newclass nowd;
column obsno row var1 var2 var3;
title 'Could use NOPRINT option on OBSNO or ROW if want to hide';
define obsno / order;
define row / order;
define var1 / 'Name/Sex';
define var2 / 'Age';
define var3 / 'Height/Weight';
compute after obsno;
line ' ';
endcomp;
run;
ods pdf close;
[/pre]
deleted_user
Not applicable
Hi Cynthia,

Thank you so very much. This is exactly what I needed!

Best regards,
Thomas

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 1626 views
  • 0 likes
  • 2 in conversation