data mydata; set mydata;
if bar<mid1 then in_color=color1;
else if bar <mid2 then in_color=color2;
else in_color=color3;
run;
/*
To sort the data in the y-axis by the data-order, I assign a numeric variable,
and then later use a user-defined format to have the number print as the text name.
*/
data mydata; set mydata;
data_order+1;
run;
proc sql;
select count(*)-1 into :lines from mydata;
quit; run;
data mydata; set mydata;
y_line=&lines-data_order+1;
run;
data ignore_error;
function='seterror'; size=1000; output;
function=''; size=.; output;
run;
data anno_table; set mydata;
length function $8 color $8 style $20 text $50 html $100;
when='a';
/* Label in left column of each line */
xsys='1'; ysys='1';
function='label';
x=0;
y=(100/&lines)*y_line+((100/&lines)/2);
position='4';
text=trim(left(measure));
/* You could have a separate drilldown for each measure, etc */
html='href='||quote(trim(left('iPhone_dashboard_info.htm')));
if bar ne . then color="&dark";
else color="&darker";
output;
/* Red 'alert' dot, if you're in worst category */
if upcase(in_color)=upcase("&badcolor") then do;
x=3;
position='5';
size=.6;
style='"webdings"';
text='6e'x;
color='red';
output;
end;
style='';
size=.;
/* Bar value column, just to the left of the bullet graph */
color="&dark";
xsys='2'; x=-.06; position='4';
if bar ne . then text=put(bar*100,comma7.1);
else text='';
output;
/* CV value column, to the left of bar value column */
color="&dark";
xsys='1'; x=54; position='4';
if cv ne . then text=put(cv,comma7.2);
else text='';
output;
/* dark black bullet/bar representing data */
xsys='2';
function='move';
x=0;
y=(100/&lines)*y_line+((100/&lines)/2);
output;
function='draw'; color="black"; line=1;
size=8; /* this is the width of the black line (which is the 'bar' in the bullet graph) */
x=bar;
output;
/* Line between (below) each label */
function='move';
xsys='3'; x=0;
ysys='1';
y=(100/&lines)*y_line;
output;
function='draw'; line=1; size=1;
if bar=. then color='gray99';
else color='grayee';
x=100;
output;
run;
data anno_table; set ignore_error anno_table;
run;
data anno_other;
length function $8 style $20 text $80;
data anno_other; set ignore_error anno_other;
run;
/* Modify a style, so it has a black/dark background in the webpage */
ods path work.template(update) sashelp.tmplmst;
proc template;
define style styles.iphone;
parent = styles.default;
replace colors / "docbg" = cx111111;
replace Output from Container / bordercolor = cxbbbbbb;
end;
GOPTIONS DEVICE=png;
/* This is the size of the iPhone Screen */
*goptions xpixels=320 ypixels=480;
/* But the mobile-Safari browser doesn't show web pages at that resolution,
so let's make it twice as big. Also, it's better to create the png file
as 'bigger' than you want it, so the resolution looks good when you
'Zoom' in with your fingers. */
*goptions xpixels=640 ypixels=960;
/* But, since you're going to display in the mobile-Safari browser,
you need the size to be larger in the x-direction (since the browser is
consuming space at the top/bottom in the Y direction */
goptions xpixels=750 ypixels=960;
/*
You could now mail the dashboard to someone (ie, mail it to their iPhone)
using code like the following...
(I have commented out the code, so it doesn't send me the dashboard every
time it's run though :)
*/