BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
_Manhattan
Obsidian | Level 7

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
Obsidian | Level 7

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

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