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
SAS Super FREQ
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,

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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