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.
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:
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
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:
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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.