BookmarkSubscribeRSS Feed
Ethen
Calcite | Level 5

Hi everyone!

 

I have the following code and it works fine, except that I like to be able to format the value in the Csal, Cuni and Csalt variables, such as making the font color or back ground color of the values in the Csal, Cuni and Csalt variables different than the texts preceding them.

 

I appreciate any help you could provide!

 

compute after / style=Header{just=l fontweight=bold fontsize=14pt};
region = 'All Regions';
Csal = left(put(salesmn,dollar10.));
Cuni = left(put(unit_pricemn,dollar10.));
Csalt = left(put(sales_taxmn,dollar10.));
line "^{style[textdecoration=underline]Averages for These Regions}";
line "Sales: " Csal $varying50.;
line "Unit Price: " Cuni $varying50.;
line "Sales Tax: " Csalt $varying50.;
endcomp;
run;

 

Ethen,

 
4 REPLIES 4
SuryaKiran
Meteorite | Level 14

You call define with foreground= or background=

Check this out:

proc format;
value $stat 'Normal'='green'
'Underweight'='orange'
'Overweight'='red';
run;
proc report data=sashelp.heart;
column bp_status weight_status ageatstart;
define bp_status /group ;
define weight_status /group;
define ageatstart/mean format=8.2;
compute weight_status;
call define(_col_,'style','style={foreground=$stat.}');
endcomp;
run; 
Thanks,
Suryakiran
Cynthia_sas
Diamond | Level 26

Hi:

  If you want to change the font color of text in a LINE statement, you have limited choices. Either you change the color of the WHOLE string or you use ODS ESCAPECHAR, as shown below:

use_escapechar_line.png

 

  If you want to use the normal RBREAK statement and a CALL DEFINE, then you can change foreground color and background color, to produce this:

use_rbreak.png

using this code:

use_rbreak_code.png

 

Hope this helps,

Cynthia

Ethen
Calcite | Level 5

Hi Cynthia!

 

Thank you!  I appreciate your time very much!

 

Your codes worked exactly the way I needed for it to work.

 

Thanks, again!

 

Ethen,

 

Ethen
Calcite | Level 5

HI Suryakiran!

 

Thank you!  I appreciate your time very much!

 

Your codes worked, but they applied the styles to the values in the column and not the line statement.

 

Thanks!

 

Mark,

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1460 views
  • 1 like
  • 3 in conversation