BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Here is the code I am using to display text but I cannot figure out the correct control code for underline.

ods rtf text = "^S={font_size=12pt font_face='Times Roman' font_weight=bold just=l } Gender";

Can anyone help me?

Thanks,
Susan
6 REPLIES 6
David_SAS
SAS Employee
In SAS 9.2 you can specify textdecoration=underline.

-- David Kelley, SAS
deleted_user
Not applicable
Thanks David,
How do I do this in 9.1?
Andre
Obsidian | Level 7
Try this to see how

[pre]
ods rtf file='d:\temp\underline.rtf';
proc print data=sashelp.class(obs=1);run;
ods rtf text = "^S={font_size=12pt font_face='Times Roman' font_weight=bold just=l } Gender";
run;
ods rtf text = "^S={font_face='Times Roman'
font_weight=bold } ^{style [textdecoration=underline fontsize=12pt just=l]Gender} ";
run;
quit;


ods rtf close;

[/pre]

BUT i do'nt remember if ods text was working under 9.1.3

Andre
Cynthia_sas
SAS Super FREQ
Hi:
If you are using RTF then you either:
1) need to use ODS control string \ul and \ul0 to turn underlining on and off for a word or text string (this method also needs for PROTECTSPECIALCHARS=OFF
or
2) if you are using SAS 9.2, use the TEXTDECORATION style attribute

The example below shows a few different ways to do underlining. The first example shows the text_decoration method and the second example shows the \ul method. Both methods show the use of the original ^S= syntax, which is what you should use for SAS 9.1.3. If you do have SAS 9.2, then there is alternate "function call" style syntax, that is described in this paper on page 2:
http://www2.sas.com/proceedings/sugi31/227-31.pdf

Note that, if you have SAS 9.1.3, then the Example 2 method is probably the one you would use. I used the underline in a few different places so you could see the method.

(Also, you cannot cut and paste directly from the pre-formatted posted code in the forum window into SAS -- you'd have to cut and paste the pre-formatted code from the forum window into some application, like Word, that respected the line feeds and carriage control characters and then cut and paste again from Word into your SAS Editor.)

cynthia
[pre]

** Example 1;
ods rtf file='c:\temp\rtf_under1.rtf' style=journal startpage=no;

ods escapechar='^';
ods rtf text = "^S={font_size=12pt font_face='Times Roman' font_weight=bold just=l textdecoration=underline} ODS Style Method";
proc tabulate data=sashelp.class;
title 'Example 1';
class sex /style={cellwidth=2in};
var age height weight;
table sex all='^S={textdecoration=underline}Average',
mean*(age height weight) /
box={label='Gender Report' s={textdecoration=underline just=l}};
run;
ods rtf text = "^S={textdecoration=underline font_face='Times New Roman' just=l} RTF Method";
ods rtf close;

** Example 2;
ods rtf file='c:\temp\rtf_under2.rtf' style=journal startpage=no;

ods escapechar='^';
ods rtf text = "^S={font_size=12pt font_face='Times Roman' font_weight=bold just=l protectspecialchars=off} \ul{ODS Style Method}\ul0";
proc tabulate data=sashelp.class;
title 'Example 2';
class sex /style={cellwidth=2in};
var age height weight;
table sex all="^S={protectspecialchars=off}\ul{Average}\ul0",
mean*(age height weight) /
box={style={protectspecialchars=off just=l} label='\ul{Gender Report}\ul0'};
run;
ods rtf text = "^S={protectspecialchars=off font_face='Times New Roman' just=l} \ul{RTF Method}\ul0";
ods rtf close;
[/pre]
Andre
Obsidian | Level 7
Hi Cynthia,

About this version of my answer which is working well in matter of underlining under 9.2.3
i would have your advice upon
[pre]
the difference in use between ^S=[ and ^{style [
and also about the documentation where it is not clear which arguments are allowed inside [ ] of the second style
[/pre]

[pre]
ods escapechar='^';
ods rtf file='d:\temp\underline.rtf';
proc print data=sashelp.class(obs=1);run;
ods rtf text ='^S={font_size=12pt font_face="Times Roman" font_weight=bold just=l protectspecialchars=off} \ul{Gender}\ul10';
run;
ods rtf text = "^{style [textdecoration=underline fontsize=12pt just=l font_face='Times New Roman' font_weight=bold]Gender} ";
run;
quit;
ods rtf close;
[/pre]

Andre
Cynthia_sas
SAS Super FREQ
Hi, Andre:
In most instances, it is OK to use either form of ESCAPECHAR style syntax. In 9.2, I try to use the new syntax, but it is slightly more verbose and if I'm not doing heavy nesting of style attributes (possible with new function style syntax, but not possible with the original syntax) -- sometimes I end up using the older syntax just because
1) I can post code that will work in either 9.1.3 or 9.2 without having to know what version someone is running
2) I have programs already written that use the original syntax and when I'm trying to blitz in without rewriting a program, I will tend to post the already written code

Also, in some (very few) instances, it is possible for the older syntax to work, but the newer syntax may not work. This has to do primarily with what was OK to be changed style-wise and where the changed needed to be made for the destination (at the cell level or within the cell). In the older syntax, the style override applied to the contents of what was contained within a table cell's boundaries.

In the newer syntax, the style override with nesting style attribute capability meant that the style might not get applied at the cell level but would be applied only to the individual words/text strings within a cell. Most style attributes, whether you use the new [...] to enclose the attribute/value pairs or {...} in the original syntax are OK to use for style overrides.

The particular problem child that I remember is that URL= worked as a style attribute override in the original syntax, but in the newer syntax (possibly for RTF, possibly for PDF), the URL style attribute didn't work. There may be others -- but they are fairly few and far between. Most of the time I just do fonts and colors and cellwidths and those all seem to work as attributes whether I am coding the original syntax or the new syntax.

Using Markup tags <tag> or RTF control strings might be trickier, but the code that I posted works for me in SAS 9.2 and I remember that it also worked in SAS 9.1.3 (although I no longer have that version to test on anymore).

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
  • 6 replies
  • 11229 views
  • 0 likes
  • 4 in conversation