BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jk8668
Fluorite | Level 6

Hi, please let me know if anyone knows how to do the following.

 

I am combining 2 variables (Variable1 and Variable2) and creating a new variable. I am using this New variable in generating RTF file.

How can I make part of this New variable (Variable 2) in BOLD in the RTF file?

 

New Variable= Variable1+ Variable 2

1 ACCEPTED SOLUTION

Accepted Solutions
Vince_SAS
Rhodochrosite | Level 12

Try this:

 

*  Close all open ODS destinations;

ods _all_ close;

*  Create the sample data;

data work.class;
set sashelp.class;
length agesex $100;
agesex = strip(put(age, best.)) ||
               '^{style [font_weight=bold]' || strip(sex) || '}';
run;

*  Define the escape character;

ods escapechar='^';

*  Create the output using various destinations;

ods html  file='test.html' path='C:\temp';
ods pdf   file='C:\temp\test.pdf';
ods rtf   file='C:\temp\test.rtf';
ods Excel file='C:\temp\test.xlsx';

proc print data=work.class; 
  var agesex;
run; quit;

ods _all_ close;

Vince DelGobbo

SAS R&D

View solution in original post

6 REPLIES 6
Dinesh2
Calcite | Level 5
The closest answer I found is on this link: http://www2.sas.com/proceedings/forum2007/151-2007.pdf.

However, when you output the rtf file and open it with microsoft word, you should be able to use the bold option I suppose. Hope this helps.
jk8668
Fluorite | Level 6
Thanks Dinesh
Vince_SAS
Rhodochrosite | Level 12

Does this give you the desired result?

 

*  Close all open ODS destinations;

ods _all_ close;

*  Create the sample data;

data work.test;
new_variable = 'This text is normal weight ' ||
               '^{style [font_weight=bold]and this text is bold}';
run;

*  Define the escape character;

ods escapechar='^';

*  Create the output using various destinations;

ods html  file='test.html' path='C:\temp';
ods pdf   file='C:\temp\test.pdf';
ods rtf   file='C:\temp\test.rtf';
ods Excel file='C:\temp\test.xlsx';

proc print data=work.test; run; quit;

ods _all_ close;

 

Vince DelGobbo

SAS R&D

jk8668
Fluorite | Level 6

Thanks  Vince.

It's not working for my scenario. The variable is not resolving in the RTF file, it's just printing the variable name.

 

For ex: I am combining AGE and SEX variables and creating new variable AGESEX. When I generate an RTF file, I want SEX part in BOLD and age in normal font.

 

When I used your code to generate RTF,  instead of printing the values of SEX (Male or Female), it was printed as SEX in BOLD.

 

EX:

SUBJECT  AGESEX

1                43SEX

2                23SEX

3                32SEX

 

 

 

Vince_SAS
Rhodochrosite | Level 12

Try this:

 

*  Close all open ODS destinations;

ods _all_ close;

*  Create the sample data;

data work.class;
set sashelp.class;
length agesex $100;
agesex = strip(put(age, best.)) ||
               '^{style [font_weight=bold]' || strip(sex) || '}';
run;

*  Define the escape character;

ods escapechar='^';

*  Create the output using various destinations;

ods html  file='test.html' path='C:\temp';
ods pdf   file='C:\temp\test.pdf';
ods rtf   file='C:\temp\test.rtf';
ods Excel file='C:\temp\test.xlsx';

proc print data=work.class; 
  var agesex;
run; quit;

ods _all_ close;

Vince DelGobbo

SAS R&D

jk8668
Fluorite | Level 6

Thanks so much vince_sas. It's working.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 10559 views
  • 3 likes
  • 3 in conversation