The SAS Output Delivery System and reporting techniques

conditional formatting

Reply
Occasional Contributor
Posts: 19

conditional formatting

I have two columns in SAS (Current ranking, previous ranking). IF the difference (Previous-current) ex: 5 (P) -1 (C) =4 between the two columns in postive, then an arrow mark  (Green) poing upwards show and then if it is negative, red color arrow downards, if the difference is zero then yellow arrow (pointing 180 degrees). could you please provide a code or any source I can exactly look into.

SAS Super FREQ
Posts: 8,868

Re: conditional formatting

Posted in reply to SMohanReddy

Hi:

  First you need the images. Let's assume the names of the images are arrow_green.png, arrow_red.png and arrow_left.png. Then you need the code. If you need to do the calculation AND the traffic lighting in the same program, then PROC REPORT would be my procedure of choice.

  The code below produced the attached screen shot. I didn't do anything to resize the images to be smaller and I only used 3 obs to make the final report. But it shows making a calculation and doing the trafficlighting.

cynthia

ods pdf file='c:\temp\tlite_arrow.pdf';

   

proc report data=sashelp.class nowd;

  column name age sex height weight calccol arrow;

  where name in ('Alfred', 'Joyce', 'Alice' );

  title 'use arrows';

  define name / order;

  define age / display;

  define sex / display;

  define height / analysis;

  define weight / analysis;

  define calccol / computed;

  define arrow / computed;

  compute calccol;

    calccol = weight.sum - height.sum;

  endcomp;

  compute arrow;

    if calccol lt 0 then do;

       call define (_col_,'style','style={preimage="c:\temp\Arrow_left.png"}');

    end;

    else if 1 < calccol le 40 then do;

       call define (_col_,'style','style={preimage="c:\temp\Arrow_red.png"}');

    end;

    else if calccol gt 40 then do;

       call define (_col_,'style','style={preimage="c:\temp\Arrow_green.png"}');

    end;

  endcomp;

run;

ods _all_ close;


use_arrows.png
Ask a Question
Discussion stats
  • 1 reply
  • 391 views
  • 1 like
  • 2 in conversation