DATA Step, Macro, Functions and more

Line statement in compute bloc

Reply
Occasional Contributor
Posts: 5

Line statement in compute bloc

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,

 
Valued Guide
Posts: 559

Re: Line statement in compute bloc

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
SAS Super FREQ
Posts: 9,324

Re: Line statement in compute bloc

Posted in reply to SuryaKiran

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

Occasional Contributor
Posts: 5

Re: Line statement in compute bloc

Posted in reply to Cynthia_sas

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,

 

Occasional Contributor
Posts: 5

Re: Line statement in compute bloc

Posted in reply to SuryaKiran

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,

Ask a Question
Discussion stats
  • 4 replies
  • 97 views
  • 1 like
  • 3 in conversation