I have the following code:
Data year3_insur; Set year2_insur;
length newvar $20;
newvar=cat(put(Row_Percent, 4.1),' [',put(Lower_CL, 4.1),'-',put(Upper_CL, 4.1),']'); DROP RowPercent RowLowerCL RowUpperCL ; Label newvar="% [95% CL]"; Run;
It concatenates 3 numeric variables into a single string that is put into a Proc Report; the string looks like: 90.0 [88.8-99.99].
I want to bold the 90.0 numbers (Row_Percent variable). I've tried using the ODS escapechar feature, but can't get it to work. I'm currently writing it as:
newvar=cat(put(Row_Percent, 4.1)^{style [font_weight=bold],' [',put(Lower_CL, 4.1),'-',put(Upper_CL, 4.1),']');
What am I doing wrong and how can I make this work?
I see an opening curly brace (before SYTLE) but no closing one and it's not part of the text?
Full example to test?
Similar to this question I believe:
https://communities.sas.com/t5/ODS-and-Base-Reporting/Applying-superscript-to-a-variable-instead-of-...
I want to bold the 90.0 numbers (Row_Percent variable). I've tried using the ODS escapechar feature, but can't get it to work.
It appears than you are attempting to add characteristics to the value of a variable.
You do not get to have properties like "bold" as part of the value of a SAS variable. You have to add instructions elsewhere, such as with a Format or style option override.
Trivial if you left the 90.0 as a separate variable. Once you make variables holding multiple values then things get very difficult for such.
@ballardw wrote:
You do not get to have properties like "bold" as part of the value of a SAS variable.
I think it may be possible as in the linked example with the superscript added in to the variable value.
EDIT: Not within a data set, but as output to an Excel file, PDF, HTML, Word doc should be possible.
data have;
input v lower upper;
newvar=cat(put(v,4.1),'~S={font_weight=bold} [',put(Lower, 4.1),'-',put(Upper, 4.1),']');
cards;
0.12 0.01 0.24
0.22 0.12 0.54
;
ods escapechar='~';
ods rtf file='c:\temp\temp.rtf' style=journal bodytitle;
proc report data=have nowd;
run;
ods rtf close;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.