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

 

Hi Experts,

 

Is it possible to highlight the specific text within a cell in proc report

e.g. if i have text as 'AAA BBB CCC' so i wanted to either highlight 'BBB' alone or just change the font color of only that text. Is it possible, any suggestions.

 

data have;
txt='AAA BBB CCC';
run;

 ods listing close;
 ods pdf file="..../sample.pdf";
PROC REPORT DATA=have LS=132 PS=60  SPLIT="/" CENTER style(summary)=Header;
COLUMN txt  ;
DEFINE  txt / DISPLAY  WIDTH=30    SPACING=2   LEFT " "  ;
run;
 title;
 ods pdf close;
 ods listing;

 image.png

 

Thanks,
Jag
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

Good call. You need a compute block unless you're going to add ODS ESCAPECHAR style functions to the actual data. In this example, I just created a new report item and did the manipulation inside a COMPUTE block.

Cynthia

use_ods_escapechar.png

View solution in original post

3 REPLIES 3
ballardw
Super User

My guess is that you would need a compute block in Proc Report and parse the string to set the attributes for the bits you want highlighted. Anything else is going to have the text properties the same for the entire cell.

 

Some possibilities might be:

If the position of the text you want to highlight could be treated as the same in each bit of text then split the next into two or three variables and then the single value would be a single cell that could be highlighted with the typical traffic lighting techniques.

 

Depending on what is needed perhaps a different display approach entirely such as the Report Writing Interface . Any summary calculations would need to be done first.

 

ODS Text statements though cumbersome would do this but likely not what you want if there are other fields/calculations involved.

 

Building the string to include native codes to set properties and not relying on strictly ODS style properties. The RAW function used with ODS ESCAPECHAR will insert HTML or RTF codes (not PDF though)

 

Cynthia_sas
SAS Super FREQ

Hi:

Good call. You need a compute block unless you're going to add ODS ESCAPECHAR style functions to the actual data. In this example, I just created a new report item and did the manipulation inside a COMPUTE block.

Cynthia

use_ods_escapechar.png

Jagadishkatam
Amethyst | Level 16

Thank you @Cynthia_sas, the solution worked.

 

Also Thank @ballardw for the suggestion of ods escapechar="^".

 

I tried the ods escapechar="^" option as below and it gave me the expected result.

 

data have;
txt='AAA BBB CCC';
comment=tranwrd(txt,'BBB','^S={foreground=red}BBB');
comment=tranwrd(comment,'BBB','BBB^S={}');
run;

 ods listing close;
 ods pdf file="./sample.pdf";
  ods escapechar="^";
PROC REPORT DATA=have LS=132 PS=60  SPLIT="/" CENTER style(summary)=Header;
COLUMN comment  ;
DEFINE  comment / DISPLAY  WIDTH=30    SPACING=2   LEFT " "  ;
run;
 title;
 ods pdf close;
 ods listing;

 

image.png

Thanks,
Jag

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
  • 2161 views
  • 3 likes
  • 3 in conversation