BookmarkSubscribeRSS Feed
SMohanReddy
Obsidian | Level 7

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.

1 REPLY 1
Cynthia_sas
Diamond | Level 26

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

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
  • 1 reply
  • 1303 views
  • 1 like
  • 2 in conversation