The SAS Output Delivery System and reporting techniques

Splitting variables and observations

Reply
N/A
Posts: 0

Splitting variables and observations

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
SAS Super FREQ
Posts: 8,743

Re: Splitting variables and observations

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]
N/A
Posts: 0

Re: Splitting variables and observations

Hi Cynthia,

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

Best regards,
Thomas
Ask a Question
Discussion stats
  • 2 replies
  • 291 views
  • 0 likes
  • 2 in conversation