The SAS Output Delivery System and reporting techniques

Adding internal borders for separate sections

Reply
N/A
Posts: 0

Adding internal borders for separate sections

Hi,

I have some SAS output that needs to be printed in a tabular form and exported to a Word document. The SAS output has several sections corresponding to a group variable. So far I have;

1. Organize the output into a SAS data set. Use PROC PRINT with BY and ID statements to create a tabular output with separate sections according to the BY groups.

2. Use ods rtf to put the tabular output in a rtf file and proc template to change style settings.

The rtf output looks almost like what I need, except the table needs internal lines to delineate sections created by the “BY” statement in “PROC PRINT”. The options for “rules” in define styles in Proc Template does not seem to extend to this case.

Does anyone have any experience with doing this? Thanks for any tips/advice you can share!

SL
N/A
Posts: 0

Re: Adding internal borders for separate sections

Unfortunately, the ability to specify a line to delineate between bygroups is not available in Proc Print or in Proc Template.
N/A
Posts: 0

Re: Adding internal borders for separate sections

Thanks. what a bummer. But !!

Is there an alternative procedure that can do it relatively painlessly?
SAS Super FREQ
Posts: 8,740

Re: Adding internal borders for separate sections

Hi:
I agree that the capability is not there in PROC PRINT. However if you combine RTF control strings with Proc Template, it is possible to get a line either ABOVE the byline or BELOW the byline.

I used the only RTF control strings that I know for lines: \brdrb (means border bottom) and \brdrs (means border solid) and \brdrt (means border top)

The first style template, in the program below, MYRTF_DIV has a line under the byline. For that template, you also need a line (\line) ABOVE the table, so that the line for the byline does not sit on top of the table.

The second style template, in the program below, MYRTF_ALT has a line above the by line. In this instance, you don't need a blank line on top of the table. And then the third style template just does a line above and a line below.

This may or may not be the look you want. I'm sure that with a little research into RTF control strings, you may be able to come up with a different look.

cynthia
[pre]
options nodate nonumber orientation=portrait center;
ods path work.templ(update)
sashelp.tmplmst(read);

proc template;
define style myrtf_div;
parent=styles.rtf;
style Byline from Byline/
pretext='\brdrb\brdrs';
style Table from Table /
pretext = '\line';
end;

define style myrtf_alt;
parent=styles.rtf;
style Byline from Byline/
pretext='\brdrt\brdrs';
end;

define style myrtf_both;
parent=styles.rtf;
style Byline from Byline/
pretext='\brdrt\brdrs \brdrb\brdrs';
style Table from Table /
pretext = '\line';
end;
run;

ods listing close;
proc sort data=sashelp.class out=class;
by sex;
run;

ods rtf file='c:\temp\div1.rtf' style=myrtf_div;
proc print data=class;
by sex;
var name age height;
run;
ods rtf close;

ods rtf file='c:\temp\div2.rtf' style=myrtf_alt;
proc print data=class;
by sex;
var name age height;
run;
ods rtf close;

ods rtf file='c:\temp\div3.rtf' style=myrtf_both;
proc print data=class;
by sex;
var name age height;
run;
ods rtf close;
[/pre]
Ask a Question
Discussion stats
  • 3 replies
  • 132 views
  • 0 likes
  • 2 in conversation