BookmarkSubscribeRSS Feed
SAS93
Quartz | Level 8

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? 

5 REPLIES 5
Reeza
Super User

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-...

ballardw
Super User

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.

Reeza
Super User

@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. 

 

 

Reeza
Super User
And what's the final output format? This can make a difference.
Ksharp
Super User
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;

Ksharp_0-1642681095591.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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