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

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 225 views
  • 2 likes
  • 2 in conversation