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

Hi! 

 

I have a proc report table that I'm producing and I need to highlight the first word in the values.  Is there a way to code for that in the proc report statement.

Also, if anyone would know how to code something in the middle of the string (ex:  4dr, 2dr) that could be helpful too.

 

I used a SAS dataset to give a basic example of the code and output.

8b10ebf7-6ee9-45fd-91c9-48459897e0c4.png

data audi;
set sashelp.cars;
where make="Audi";
run;
 
ods listing close;
ods excel file="C:\test.xlsx";
ods excel options(sheet_name="test" sheet_interval="none");
proc odstext;
  p "This gives Audi cars" / style=[font_weight=bold font_size=16pt cellwidth=15in];
  p " ";
run;
proc report data=audi
style(report)={font_size=12pt}
style(header)={font_size=12pt background = aliceblue} 
style(column)={font_size=12pt};
column (make model type);
define make / 'Make of car' display;
define model/'Model of car' display;
define type / 'Type of car' display;
run;
ods excel close;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  ODS ESCAPECHAR to the rescue. For most ODS destinations, you can use ODS ESCAPECHAR to insert style overrides for pieces of a string. This is easier to do in a DATA step before your reporting step so that you can use the SCAN, SUBSTR and CAT functions to rebuild the string with the ESCAPECHAR overrides.

  Here's an example:

Cynthia_sas_0-1699637762920.png

  This works in ODS HTML and ODS EXCEL, as shown above. I added the colors with the bold, so the changes would stand out in the screen shot. Of course, this does assume that the strings 4dr and 2dr are all you're looking for and that the string is exactly 3 characters long and that by the first word, you meant the first "chunk" of the Model variable up to the first space in the value.

Cynthia

View solution in original post

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:

  ODS ESCAPECHAR to the rescue. For most ODS destinations, you can use ODS ESCAPECHAR to insert style overrides for pieces of a string. This is easier to do in a DATA step before your reporting step so that you can use the SCAN, SUBSTR and CAT functions to rebuild the string with the ESCAPECHAR overrides.

  Here's an example:

Cynthia_sas_0-1699637762920.png

  This works in ODS HTML and ODS EXCEL, as shown above. I added the colors with the bold, so the changes would stand out in the screen shot. Of course, this does assume that the strings 4dr and 2dr are all you're looking for and that the string is exactly 3 characters long and that by the first word, you meant the first "chunk" of the Model variable up to the first space in the value.

Cynthia

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 496 views
  • 2 likes
  • 2 in conversation