BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abbym
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

4 REPLIES 4
Cynthia_sas
SAS Super FREQ
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
abbym
Fluorite | Level 6

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;
Ksharp
Super User

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

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

x.png

 

abbym
Fluorite | Level 6

 

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!

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
  • 4 replies
  • 3589 views
  • 2 likes
  • 3 in conversation