Hi @nickspencer
I think the following material could be a great resource: https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/116-31.pdf
Hereafter is an example of a possible output.
Hope this helps
Best,
ods excel file="/path/retail_dashboard.xlsx";
data retail;
set sashelp.retail (keep=date sales);
_lag_sales = lag(sales);
year = year(date);
month = month(date);
run;
proc report data=retail nowd;
column year month sales _lag_sales Sales_ind Sales_month;
define year / group;
define month / group;
define sales / display format=dollar8.2;
define _lag_sales / display noprint;
define Sales_ind / computed;
define Sales_month / computed;
/*Sales_ind: colored circle (red, yellow or green) based on current month sales */
compute Sales_ind / character;
if 0 <= sales < 500 then do; /* determine the threshold */
Sales_ind ="O";
call define(_col_, 'style', 'style=[foreground=red font_weight=bold');
end;
else if 500 <= sales < 800 then do; /* determine the threshold */
Sales_ind ="O";
call define(_col_, 'style', 'style=[foreground=yellow font_weight=bold');
end;
else if 800 <= sales then do; /* determine the threshold */
Sales_ind ="O";
call define(_col_, 'style', 'style=[foreground=green font_weight=bold]');
end;
endcomp;
/*Sales_month should have a little line graph to show the sales increase or decrease over month.*/
compute Sales_month / character;
if Sales < _lag_sales then do;
Sales_month="➘";
call define(_col_, 'style', 'style=[foreground=red font_weight=bold ');
end;
if Sales = _lag_sales then do;
Sales_month="➙";
call define(_col_, 'style', 'style=[foreground=yellow font_weight=bold');
end;
if Sales > _lag_sales then do;
Sales_month="➚";
call define(_col_, 'style', 'style=[foreground=green font_weight=bold');
end;
endcomp;
run;
ods excel close;
Hi @nickspencer
I think the following material could be a great resource: https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/116-31.pdf
Hereafter is an example of a possible output.
Hope this helps
Best,
ods excel file="/path/retail_dashboard.xlsx";
data retail;
set sashelp.retail (keep=date sales);
_lag_sales = lag(sales);
year = year(date);
month = month(date);
run;
proc report data=retail nowd;
column year month sales _lag_sales Sales_ind Sales_month;
define year / group;
define month / group;
define sales / display format=dollar8.2;
define _lag_sales / display noprint;
define Sales_ind / computed;
define Sales_month / computed;
/*Sales_ind: colored circle (red, yellow or green) based on current month sales */
compute Sales_ind / character;
if 0 <= sales < 500 then do; /* determine the threshold */
Sales_ind ="O";
call define(_col_, 'style', 'style=[foreground=red font_weight=bold');
end;
else if 500 <= sales < 800 then do; /* determine the threshold */
Sales_ind ="O";
call define(_col_, 'style', 'style=[foreground=yellow font_weight=bold');
end;
else if 800 <= sales then do; /* determine the threshold */
Sales_ind ="O";
call define(_col_, 'style', 'style=[foreground=green font_weight=bold]');
end;
endcomp;
/*Sales_month should have a little line graph to show the sales increase or decrease over month.*/
compute Sales_month / character;
if Sales < _lag_sales then do;
Sales_month="➘";
call define(_col_, 'style', 'style=[foreground=red font_weight=bold ');
end;
if Sales = _lag_sales then do;
Sales_month="➙";
call define(_col_, 'style', 'style=[foreground=yellow font_weight=bold');
end;
if Sales > _lag_sales then do;
Sales_month="➚";
call define(_col_, 'style', 'style=[foreground=green font_weight=bold');
end;
endcomp;
run;
ods excel close;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.