SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
_Manhattan
Quartz | Level 8

Hey Guys,

 

quick question. I want to print a table via proc report and highlight certain parts via bold/italic/underlining. Unfortunately, I only manage to print a whole column bold like this:

Screen.JPG
But I would like the table to look something like this (e. g. if I only want to print the "4dr" part as bold) --> So everything besides "4dr" should be plain text and "4dr" should be printed as bold text.

Screen2.JPG

My code so far looks like this and I did not manage to customize it accordingly

data cars;
set sashelp.cars (obs=20);
run;
ods pdf file="yourpath\test.pdf";
title;

ods pdf startpage=no;
ods layout start width=19cm height=28cm;

proc report data=cars;
	column Make Model Type;
	define Make / "MAKE" ;
	define Model / "MODEL" ;
	define Type / "TYPE" ;
	compute Model;
	if Make = 'Acura' then call define(_col_,'style','style={fontweight=bold}');
	endcomp;
run;


ods layout end;
ods pdf close;

If you have got any hints for me how to achieve the desired result I'd be grateful. Thank you!

 

Kind regards

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Since it looks like you are using ODS output you should be able to use ODS ESCAPECHAR to embed the style setting into the value of your character variable.  Change the FONTWEIGHT to make it bold or heavy.  Make sure to make the variable long enough to contain the extra characters.

 

Example Let's also change the color to make it more obvious in the output.

data class ;
  set sashelp.class;
  where name=:'J';
  length boldname $100 ;
  boldname = tranwrd(name,'an','(*ESC*){style [fontweight=extra_bold color=red]an}');
  format boldname;
run;
proc print data=class;
run;

Result

Tom_0-1695490664487.png

 

 

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Since it looks like you are using ODS output you should be able to use ODS ESCAPECHAR to embed the style setting into the value of your character variable.  Change the FONTWEIGHT to make it bold or heavy.  Make sure to make the variable long enough to contain the extra characters.

 

Example Let's also change the color to make it more obvious in the output.

data class ;
  set sashelp.class;
  where name=:'J';
  length boldname $100 ;
  boldname = tranwrd(name,'an','(*ESC*){style [fontweight=extra_bold color=red]an}');
  format boldname;
run;
proc print data=class;
run;

Result

Tom_0-1695490664487.png

 

 

_Manhattan
Quartz | Level 8

Thank you so much Tom, you've saved my day 🙂

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 3 replies
  • 3376 views
  • 2 likes
  • 3 in conversation