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

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

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