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
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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