BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a client who wants a portion of their report (a rectangular range of cells inside the report) to use a different border style than the rest of the report (double lines), and there are some individual cells (not necessarily in that same range) where the data need to be underlined and/or bold based on the values, and some of the borders in the report also need to be bold (again, based on the data). Oh, and standard sizing of the cells would be good.

My question is, can I get fine enough control using ODS and PROC REPORT (we only have SAS 9.1.3 M2, I think) to do this, or do I need another strategy, like maybe just writing it out into an HTML file inside of a DATA _NULL_ and controlling the individual cells as necessary, using a CSS file to provide the basic style information?

I haven't gotten access to the current code or data yet, so I am just trying to figure out the possibilities for solving this problem. Right now, the client is exporting SAS output into Excel and manually manipulating the cells.

Thanks!
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
Much easier in SAS 9.2, than in SAS 9.1.3, but still possible, especially if you know HTML and CSS -- and you might not even need DATA _NULL_.

For example, look at some of these examples that show the use of the HTMLSTYLE attribute to pass CSS property/values to an HTML file.
http://support.sas.com/rnd/base/ods/templateFAQ/report1.html

For example, this would simulate the DOL option (which works in LISTING) using CSS properties:
[pre]
style(summary)={htmlstyle="border-top:thick double green"}; [/pre]


As for the underlining or bold based on cell values, you can accomplish that using 2 different methods with PROC REPORT:
BOLD
1) user defined format used with STYLE= override
2) CALL DEFINE statement to supply STYLE override
http://support.sas.com/kb/23/353.html (use font_weight=bold where they show background=red, for example)

UNDERLINE need to pass <U> </U> tags:
1) user defined format to pass <u> tag as PREHTML or PRETEXT ... not shown, but you could extrapolate from format for AGE how to do this.
2) CALL DEFINE method (pass HTML tags as either PREHTML or PRETEXT as shown below)
3) insert HTML tags directly into name value in data step
4) concat HTML tags directly to name value in data step
[/pre]

cynthia
[pre]
data class;
length Name $60;
set sashelp.class;
** concat <u> tag directly to name;
if name = 'John' then do;
name = catt('<u>',name,'</u>');
end;

** use Escapechar + RAW text insertion;
if name = 'William' then do;
name = catt('^R/"<u>"',name,'^R/"</u>"');
end;
run;

proc format;
value agef 12-14 = 'normal'
15-high='bold';
run;

ods listing close;
ods html3 file='showunder.html' style=journal;
ods escapechar='^';

proc report data=class nowd
style(report)={background=_undef_};
column name age sex height weight;
define name / order order=data 'Name'
style(column)={protectspecialchars=off};
** use user-defined format for bold;
define age / display
style(column)={font_weight=agef.};
define sex / display 'Gender';
define height /mean;
define weight /display;
rbreak after /summarize;
compute name;
** Use PREHTML and PRETEXT for underline;
if name = 'Alfred' then do;
call define (_col_,'style',
'style={prehtml="<u>" posthtml="</u>"}');
end;
else if name = 'Mary' then do;
call define (_col_,'style',
'style={pretext="<u>" posttext="</u>"}');
end;
endcomp;
compute height;
if name = 'Philip' then do;
call define (_col_,'style',
'style={htmlstyle=
"border-bottom:solid;border-top:solid;border-left:solid"}');
end;
endcomp;
compute weight;
if name = 'Philip' then do;
call define (_col_,'style',
'style={htmlstyle=
"border-bottom:solid;border-top:solid;border-right:solid"}');
end;
endcomp;
run;
ods html3 close;[/pre]
deleted_user
Not applicable
I wasn't quite sure how to do the double line in anything other than HTML, but I also didn't quite know to tag my output in a style(). I can figure out which type of border to use (top, bottom/ and or left/right) depending on table cell in the "hot zone" via a CALL DEFINE statement as HTML or PRETEXT. I can make the "hot zone" available to PROC REPORT as a set of macro variables or in the dataset itself.

Thanks again!
Cynthia_sas
SAS Super FREQ
Hi:
I believe that the double line and some of what you want to do are also supported with ODS RTF, if you use RTF control strings (like \dul double underline in RTF-land) or issue specific \brdrb or \brdrt commands. You can find some of them here in the RTF FAQ:
http://support.sas.com/rnd/base/ods/templateFAQ/Template_rtf.html#control
or by looking in the RTF spec:

http://www.microsoft.com/downloads/details.aspx?familyid=DD422B8D-FF06-4207-B476-6B5396A18A2B&displa... (Microsoft makes you download the current spec)
but you can find older versions here:

http://www.biblioscape.com/rtf15_spec.htm (you can find different border types, like \brdrdb for double border in the Paragraph Borders section of the doc)

cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1795 views
  • 0 likes
  • 2 in conversation