I'm on a proc report, and I want to compare two analysis variables:
var2 and var1.
if var2>var1 ==> green arrow||value(var2) (concatenation)
if var2<var1 ==> red arrow||value(var2) (concatenation)
data last_decade_data; input country:$8. date:Date9. some_cost some_metric; format date date9.; datalines; USA 15OCT2018 500 0.1 USA 16OCT2018 501 0.09 USA 17OCT2018 504 0.08 USA 18OCT2018 480 0.2 USA 19OCT2018 550 0.06 USA 20OCT2018 515 0.07 USA 21OCT2018 552 0.05 USA 22OCT2018 593 0.04 USA 23OCT2018 499 0.3 USA 24OCT2018 500 0.1 USA 25OCT2018 500 0.1 ; run; proc sql; create table test as select a.country,case when a.sum>b.pre_sum then CATS("~S={foreground=Green}~{unicode '2b06'x}~S={}",a.sum) else CATS("~S={foreground=red}~{unicode '2b07'x}~S={}",a.sum) end as Sum, case when a.avg>pre_avg then CATS("~S={foreground=Green}~{unicode '2b06'x}~S={}",a.avg) else CATS("~S={foreground=red}~{unicode '2b07'x}~S={}",a.avg) end as Avg from (select Country,sum(some_cost) as sum,avg(some_metric) as avg from last_decade_data group by country) as a left join (select Country,sum(some_cost) as pre_sum,avg(some_metric) as pre_avg from last_decade_data where date<today() group by country) as b on a.country=b.country ; quit; ods escapechar='~'; proc print data=test noobs; run; /*{unicode '2b06'x} for ArrowDown*/ /*{inocode '2bo7'x} for ArrowUp*/
I want to display the arrows in var2 next to the values.
I found this code but I can't adapt it to a proc report if you can help me please.
How about showing code for the report without the arrows and then indicate just where the arrows are supposed to appear.
How about showing code for the report without the arrows and then indicate just where the arrows are supposed to appear.
data have;
input var1 var2;
x=unicode("\u2b07");
cards;
1 2
2 4
4 2
2 1
;
ods escapechar='~';
proc report data=have nowd;
columns var1 var2 want;
define var1/display;
define var2/display;
define want/computed;
compute want/character length=100;
if var2>var1 then want=cat("~{style [foreground=green fontsize=8] ~{unicode '2b07'x}}",var2);
else if var2<var1 then want=cats("~{style [foreground=red fontsize=8] ~{unicode '2b06'x}}",var2);
else want=cats(var2);
endcomp;
run;
Thank's 👍
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: