BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tekish
Quartz | Level 8

I want to highlight Weight column in excel output.

  •   when Weight is less than Height .

 

/*SAS code*/

ods tagsets.excelxp file="bylines.xls" style=statistical

options( suppress_bylines='yes' sheet_interval='none' );

proc report data=class nowd;

column name age sex height weight ;

define name / display;

define age / display;

define sex / order;

define height / sum;

define weight / sum;

compute age;

if age < 13 then  call define(_col_,"style","style={background=red}");

endcomp;

compute weight;

if weight < height then call define(_col_,"style","style={background=blue}");

endcomp;

run;

ods _all_ close;

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Since weight and height has ANALYSIS usage, you should use .sum to refer to them.


compute weight;
if weight.sum < height.sum then call define(_col_,"style","style={background=blue}");
endcomp;

View solution in original post

4 REPLIES 4
Cynthia_sas
Diamond | Level 26
Hi:
I would expect that you are getting highlighting for AGE, but not for the WEIGHT column. When you use an analysis variable in a COMPUTE block, you do not refer to the simple name. You must use the convention varname.statistic.

So in this case, you show that statistic of SUM for HEIGHT and WEIGHT, then you need to refer to them in your COMPUTE block as:
HEIGHT.SUM and WEIGHT.SUM

or

if weight.sum < height.sum then call define(...);

cynthia
tekish
Quartz | Level 8

It works.

 

Thanks

kesete

Ksharp
Super User
Since weight and height has ANALYSIS usage, you should use .sum to refer to them.


compute weight;
if weight.sum < height.sum then call define(_col_,"style","style={background=blue}");
endcomp;
tekish
Quartz | Level 8

It works,

 

Thanks,

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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