The SAS Output Delivery System and reporting techniques

How Do I Combine Rows in Proc Report

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How Do I Combine Rows in Proc Report

I need to create a report which contains information about a set of tests, individual results from the tests, and then a column containing the mean result for these tests, as in the format below: 

 

 Wanted.PNG

However, I am ending up with the result below:

 

Actual.PNG
As can be seen, this is fine before the individual test results, but the columns after them are not displaying as required. Is there a way of doing this without splitting the data out into multiple tables? 

 

The code that I am using for this is below:

 

proc report data=data nofs spanrows split='*'
style(column)=[font=('Arial',9pt) vjust=middle]
style(header)=[font=('Arial',9pt,bold) background=_und_ vjust=middle]
style(report)=[cellpadding=3pt rules=all frame=box];
column(test_info test individual_result pooled_result further_calculations);

define test_info / order 'Test Information';
define test /  order 'Test';
define individual_result / order 'Individual Result';
define pooled_result / order 'Pooled Results';
define further_calculations / order 'Other Calculations Based on The Pooled Result';

run;

Thanks in advance!


Accepted Solutions
Solution
‎05-31-2017 10:16 AM
Super User
Posts: 9,662

Re: How Do I Combine Rows in Proc Report

apply  DISPLAY usage to the middle two variable ,not ORDER.

define test /  display 'Test';
define individual_result / display 'Individual Result';

x.png

 

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,739

Re: How Do I Combine Rows in Proc Report

Hi,
Thanks for showing your code, but you did not show ALL your code, including ODS statements -- do you want PDF or RTF output? Also, it is hard to replicate your results without any data. Someone might make some fake data, but it is just a guess as to what your work.data file looks like?

But even if you show the data, one of the issues is that PROC REPORT will want to span the left-most ORDER or GROUP items, but not the right-most items. I suspect that, if you changed your COLUMN statement like this:
column(test_info pooled_result further_calculations test individual_result ); so that pooled_result and further_calculations were moved to the left, next to test_info, that the spanning would be what you wanted, but the items would not appear in the order you want.

You might investigate the report writing interface (RWI), because it allows for more control over row spanning and column spanning.

cynthia
New Contributor
Posts: 3

Re: How Do I Combine Rows in Proc Report

Hi Cynthia,

 

Thanks for replying. The output I need is RTF, I have included the code I have used for this below. Unfortunately due to limitations within my company I'm not allowed to show any actual data so I just faked some data in the same format as what I need, hence why the tables were so generic! Again, the code used for that is below.

 

That's what I suspected, the data does need to be in the order specified above so I will investigate the RWI below (and let the person who requested it all be in one table know that it probably won't happen that way!)

 

Thanks again for your help,

Abby

 

data data;
input test_info $40. test individual_result pooled_result further_calculations;
datalines;
Multiple Columns Containing Information 1 1 1.5 5
Multiple Columns Containing Information 2 2 1.5 5
;
run;

options papersize=a4 orientation=portrait nonumber nodate;
ods rtf file="C:\Users\morelax5\Documents\Example Tables.doc" startpage=no style=MyStyleRTF;

goptions reset=all;
goptions device=zpng target=zpng xmax=8in ymax=5in hsize=8in vsize=5in xpixels=2880 ypixels=1800
rotate=portrait ftext='Arial' htext=11pt;
ods escapechar='~';

proc report data=data nofs spanrows split='*'
style(column)=[font=('Arial',9pt) vjust=middle]
style(header)=[font=('Arial',9pt,bold) background=_und_ vjust=middle]
style(report)=[cellpadding=3pt rules=all frame=box];
column(test_info test individual_result pooled_result further_calculations);

define test_info / order 'Test Information';
define test /  order 'Test';
define individual_result / order 'Individual Result';
define pooled_result / order 'Pooled Results';
define further_calculations / order 'Other Calculations Based on The Pooled Result';

run;

ods rtf close;
Solution
‎05-31-2017 10:16 AM
Super User
Posts: 9,662

Re: How Do I Combine Rows in Proc Report

apply  DISPLAY usage to the middle two variable ,not ORDER.

define test /  display 'Test';
define individual_result / display 'Individual Result';

x.png

 

New Contributor
Posts: 3

Re: How Do I Combine Rows in Proc Report

 

Odd, that's what I originally had and it didn't work which is why I changed them to order to see if it did. I've just tried again and it has worked!

Thanks!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 207 views
  • 2 likes
  • 3 in conversation