/* First, write out the kpi's ... */ %let name=dirkpi; /* 'proc gkpi' is new in v9.2 sas */ goptions device=javaimg; goptions cback=white noborder; goptions xpixels=180 ypixels=150; ods html file="&name..htm" nogtitle style=minimal; goptions ftext="albany amt/bold" htext=9pct ctext=black; title1; /* I've commented these out, because 'proc gkpi' is java-based and therefore runs very slowly. If your gauge data changes, you will have to uncomment these, and re-generate the gauge png files (which you annotate later). */ /* proc gkpi mode=basic; dial actual=.25 bounds=(-1 -.5 0 .5 1) / label='Visits vs. Last Year' colors=(cxFF6666 cxFFFFAA cxFFFFAA cx9AFF9A) format="percentn6.0" noavalue name="&name" ; run; proc gkpi mode=basic; dial actual=-.12 bounds=(-1 -.5 0 .5 1) / label='Page Views vs. Last Month' colors=(cxFF6666 cxFFFFAA cxFFFFAA cx9AFF9A) format="percentn6.0" noavalue name="&name" ; run; proc gkpi mode=basic; dial actual=-.24 bounds=(-1 -.5 0 .5 1) / label='Visits vs. Last Month' colors=(cxFF6666 cxFFFFAA cxFFFFAA cx9AFF9A) format="percentn6.0" noavalue name="&name" ; run; proc gkpi mode=basic; dial actual=.51 bounds=(-1 -.5 0 .5 1) / label='Page Views vs. Last Year' colors=(cxFF6666 cxFFFFAA cxFFFFAA cx9AFF9A) format="percentn6.0" noavalue name="&name" ; run; */ quit; ods html close; /* Now, do the rest of the dashboard... */ %let name=direct; filename odsout '.'; /* SAS/Graph imitation of ... http://www.visualmining.com/developers/examples/marketing-communications-dashboard.htm */ data bardata; format value percentn6.0; input name $ 1-20 category value; datalines; Wyldbus Comp. 1 .10 Wyldbus Comp. 2 .30 Wyldbus Comp. 3 .20 Wyldbus Comp. 4 .23 Wyldbus Cross Shop 1 .07 Wyldbus Cross Shop 2 .20 Wyldbus Cross Shop 3 .15 Wyldbus Cross Shop 4 .15 Wyldbus 1 .12 Wyldbus 2 .31 Wyldbus 3 .21 Wyldbus 4 .21 Wyldbus Pages 1 .10 Wyldbus Pages 2 .20 Wyldbus Pages 3 .20 Wyldbus Pages 4 .18 Paid Referral 1 .08 Paid Referral 2 .15 Paid Referral 3 .15 Paid Referral 4 .17 Visit Trend 1 .07 Visit Trend 2 .20 Visit Trend 3 .15 Visit Trend 4 .13 ; run; proc sql; create table bardata as select *, sum(value) as sum_value from bardata group by name; quit; run; /* Add charttips to the bars */ data bardata; set bardata; length htmlvar $500; htmlvar= 'title='||quote( trim(left(name))||'0D'x|| 'Total Page Variability: '|| trim(left(put(sum_value,percentn6.0))))|| ' href="direct_info.htm"'; run; goptions device=png; goptions nodisplay; goptions xpixels=680 ypixels=250; goptions gunit=pct htitle=8.5 ftitle="albany amt/bold" htext=6.5 ftext="albany amt"; goptions ctitle=gray33; axis1 label=none color=graybb value=(c=black justify=right) offset=(8,5); axis2 label=none color=graybb value=(c=black) order=(0 to 1.00 by .2) minor=none; pattern1 v=solid c=cxeefeee; pattern2 v=solid c=lilg; pattern3 v=solid c=bilg; pattern4 v=solid c=lime; title1 "Page Variability"; proc gchart data=bardata; hbar name / type=sum sumvar=value subgroup=category nolegend nostats noframe maxis=axis1 raxis=axis2 coutline=graybb space=1.5 html=htmlvar name="barplot"; run; /* Now, do the gmap */ data mapdata; input st $ 1-2 percent; state=stfips(st); datalines; NC .97 SC .96 VA .92 WV .93 MD .92 DE .96 GA .51 FL .55 AL .56 MS .57 TN .83 KY .88 LA .81 TX .83 OK .85 CO .88 KS .83 AR .85 NM .81 MO .85 AZ .62 CA .69 NV .63 UT .61 WA .31 OR .39 ID .36 ID .37 MT .35 WY .35 ND .72 SD .77 MN .71 IA .73 NE .73 WI .78 IL .73 MI .73 IN .77 OH .72 ME .03 VT .05 NH .04 MA .02 RI .06 CT .03 NJ .02 NY .03 PA .07 ; run; proc format; value binfmt 1='0-10' 2='10-20' 3='20-30' 4='30-40' 5='40-50' 6='50-60' 7='60-70' 8='70-80' 9='80-90' 10='90-100' ; run; data mapdata; set mapdata; format colorbin binfmt.; if percent > .90 then colorbin=10; else if percent > .80 then colorbin=9; else if percent > .70 then colorbin=8; else if percent > .60 then colorbin=7; else if percent > .50 then colorbin=6; else if percent > .40 then colorbin=5; else if percent > .30 then colorbin=4; else if percent > .20 then colorbin=3; else if percent > .10 then colorbin=2; else colorbin=1; run; /* Add charttips to the bars */ data mapdata; set mapdata; length htmlvar $500; htmlvar= 'title='||quote( trim(left(st))||': '||trim(left(put(percent,percentn6.0))))|| ' href="direct_info.htm"'; run; data mymap; set mapsgfk.us (where=(statecode not in ('AK' 'HI' 'PR'))); run; /* Create an annotated 'shadow' to go behind the map. */ data anno_shadow; set mymap; by state segment notsorted; length color function $8; xsys='2'; ysys='2'; when='B'; color='gray33'; style='msolid'; if first.state or first.segment then function='poly'; else function='polycont'; run; /* Give a little x & y offset, so it will look like a shadow */ data anno_shadow; set anno_shadow; x=x+.0022; y=y-.0030; run; goptions xpixels=700 ypixels=500; pattern1 v=s c=cxCC1100; /* red */ pattern2 v=s c=cxFF2400; pattern3 v=s c=cxFF3D0D; pattern4 v=s c=cxFF6103; pattern5 v=s c=cxFF8C00; pattern6 v=s c=cxFFE600; pattern7 v=s c=cxFFFF7E; pattern8 v=s c=cxBCED91; pattern9 v=s c=cx99CC32; pattern10 v=s c=cx308014; /* green */ goptions gunit=pct htitle=5.0 ftitle="albany amt/bold" htext=3.7 ftext="albany amt"; legend1 label=(position=top '% of Goal') position=(bottom center) across=5 shape=bar(2,2.5) value=(h=3.5 j=l) mode=share offset=(0,-9) colmajor order=descending; /* these are relatively new options */ title "Page Views By Region"; footnote h=9pct " "; proc gmap map=mymap data=mapdata all; id state; choro colorbin / midpoints = 1 to 10 by 1 legend=legend1 coutline=graycc anno=anno_shadow html=htmlvar name="map"; run; /* There's no graceful way to consume tables with 'greplay', therefore I'm creating a 'graphical' table with annotate. */ data anno_tabl; length function color $8 text $20 style $35; xsys='3'; ysys='3'; hsys='3'; when='A'; line=0; function='move'; x=5; y=30; output; color='cx7AA9DD'; style='solid'; function='bar'; x=x+60; y=y+36; output; function='move'; x=5; y=30; output; color='gray33'; style='empty'; function='bar'; x=x+90; y=y+12; output; function='move'; x=5; y=30; output; color='gray33'; style='empty'; function='bar'; x=x+90; y=y+24; output; function='move'; x=5; y=30; output; color='gray33'; style='empty'; function='bar'; x=x+90; y=y+36; output; function='label'; style="albany amt"; size=6.75; position='4'; color='white'; x=65; y=36; text="Most Cross-Shopped:"; output; y=48; text="Page Views:"; output; y=60; text="Visits:"; output; color='black'; x=94; y=36; text="Wyldbus"; output; y=48; text="36.0 M"; output; y=60; text="1.9 M"; output; run; goptions xpixels=400 ypixels=400; goptions htitle=8; title h=13pct " "; title2 c=gray33 f="albany amt/bold" h=8.5 "By The Numbers:"; footnote; proc gslide name="table" anno=anno_tabl; run; /* Do the kpi gauges. Note that "proc gkpi" is a v9.2 thing, so this will not work in v9.1.3 sas. Also, "proc gkpi" only works with dev=javaimg, and does not produce a grseg, therefore I can't greplay them like my other graphs. Instead, I have to annotate the gkpi png output into a gslide, so I can then greplay it... */ data anno_kpi; length function color text $8 imgpath $20 html $300; xsys='3'; ysys='3'; hsys='3'; when='A'; html='title="Gauge Value = 25%" href="direct_info.htm"'; function='move'; x=5; y=50; output; function='image'; x=x+42.5; y=y+50; imgpath='dirkpi.png'; style='fit'; output; html='title="Gauge Value = 51%" href="direct_info.htm"'; function='move'; x=5; y=0; output; function='image'; x=x+42.5; y=y+50; imgpath='dirkpi3.png'; style='fit'; output; html='title="Gauge Value = -24%" href="direct_info.htm"'; function='move'; x=50; y=50; output; function='image'; x=x+42.5; y=y+50; imgpath='dirkpi2.png'; style='fit'; output; html='title="Gauge Value = -12%" href="direct_info.htm"'; function='move'; x=50; y=0; output; function='image'; x=x+42.5; y=y+50; imgpath='dirkpi1.png'; style='fit'; output; run; title; footnote; proc gslide name="kpis" anno=anno_kpi; run; /* Draw the title and legend on a blank slide and save the output in a GRSEG named titles. */ goptions xpixels=850 ypixels=600; goptions htitle=4; title color=viypk ls=1.5 "Interactive Communications & Direct Marketing Metrics"; footnote; proc gslide name="titles"; run; goptions display; goptions border; goptions xpixels=850 ypixels=550; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Communications & Direct Marketing Metrics (SAS/Graph Dashboard)") style=htmlblue; proc greplay tc=tempcat nofs igout=work.gseg; tdef panels3 des='Panels' 0/llx = 0 lly = 0 ulx = 0 uly =100 urx =100 ury =100 lrx =100 lry = 0 1/llx = 0 lly = 60 ulx = 0 uly = 90 urx = 75 ury = 90 lrx = 75 lry = 60 2/llx = 75 lly = 60 ulx = 75 uly = 90 urx =100 ury = 90 lrx =100 lry = 60 3/llx = 0 lly = 0 ulx = 0 uly = 55 urx = 50 ury = 55 lrx = 50 lry = 0 4/llx =50 lly = 0 ulx =50 uly = 55 urx =100 ury = 55 lrx =100 lry = 0 ; template = panels3; treplay 0:titles 1:barplot 2:table 3:kpis 4:map des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;