Hi,
My data is like below i need to compare last month and current month data and need to highlight with up arrow or down arrow for growth or loss please provide the code thanks in advance
data input
| Month | Location | Stores |
| 11/1/2018 | Chennai | 16 |
| 11/1/2018 | Hyderabad | 12 |
| 11/1/2018 | Chennai | 14 |
| 11/1/2018 | Chennai | 12 |
| 11/1/2018 | Hyderabad | 32 |
| 11/1/2018 | Hyderabad | 14 |
| 12/1/2018 | Chennai | 17 |
| 12/1/2018 | Hyderabad | 16 |
| 12/1/2018 | Chennai | 1 |
| 12/1/2018 | Chennai | 21 |
| 12/1/2018 | Hyderabad | 12 |
| 12/1/2018 | Hyderabad | 12 |
Expected output:
attached image file
Not here to type in test data, so just some example code - untested:
proc sort data=have;
by location month;
run;
proc means data=have;
var stores;
by location month;
output out=inter sum=want;
run;
proc transpose data=inter out=want;
by location month;
var want;
idlabel month;
run;
data want;
length col $2;
set want;
array var{2};
if var{2} < var{1} then col=cats("^s={font_weight=bold font_color=red}↓ ^s={font_weight=normal font_color=black}",put(var{2},best.));
else if var{2} > var{1} then col=cats("^s={font_weight=bold font_color=green}↑ ^s={font_weight=normal font_color=black}",put(var{2},best.));
else col=strip(put(var{2},best.));
run;
ods escapechar="^";
proc report data=want;
columns _all_;
run;
Hi While am using that code showing below error.
You will need to get the special character to the output somehow, as you are not using a unicode system (and why not?) then you would need to push the symbol out some other way, maybe:
proc sort data=have;
by location month;
run;
proc means data=have;
var stores;
by location month;
output out=inter sum=want;
run;
proc transpose data=inter out=want;
by location month;
var want;
idlabel month;
run;
data want;
length col $2;
set want;
array var{2};
if var{2} < var{1} then col=cats("^s={font_weight=bold font_color=red}^{unicode 28A9} ^s={font_weight=normal font_color=black}",put(var{2},best.));
else if var{2} > var{1} then col=cats("^s={font_weight=bold font_color=green}^{unicode 26A9} ^s={font_weight=normal font_color=black}",put(var{2},best.));
else col=strip(put(var{2},best.));
run;
ods escapechar="^";
proc report data=want;
columns _all_;
run;
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.