%let name=smartphones; filename odsout '.'; /* Google search for ... mobile subscribers site:comscore.com mobile subscribers nov-10 site:comscore.com mobile subscribers dec-10 site:comscore.com etc... */ /* change the range, each time you add a new month/column of data */ PROC IMPORT OUT=pctdata DATAFILE="smartphones.xls" DBMS=EXCEL REPLACE; RANGE="Sheet1$A3:AS9"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; RUN; proc transpose data=pctdata out=pctdata; by type notsorted; run; data pctdata; set pctdata; if type='Apple (iphone)' then type='Apple (iPhone)'; format pctval percent7.0; pctval=col1; year=0; year=substr(_name_,2,4); month=0; month=substr(_name_,7,2); run; /* I don't have a value for March 2010, so I'm estimating it ... */ proc sql; create table fill_in as select unique type, pctval from pctdata where year=2010 and (month=2 or month=4); create table fill_in as select unique type, avg(pctval) as pctval from fill_in group by type; quit; run; data fill_in; set fill_in; year=2010; month=3; run; /* add the estimated value to the data */ data pctdata; set pctdata fill_in; run; /* create an 'Other' bar segment */ proc sql; create table other as select unique 'Other' as type, year, month, 1-sum(pctval) as pctval from pctdata group by year, month; quit; run; data pctdata; set pctdata other; run; data pctdata; set pctdata; length myhtml $100; if year=2010 and month=3 then myhtml= 'title='||quote( trim(left(scan(type,1,'(')))||': '||trim(left(put(pctval,percent7.1)))||'0d'x|| '(estimated)'); else myhtml= 'title='||quote(trim(left(scan(type,1,'(')))||': '||trim(left(put(pctval,percent7.1)))); run; /* Let's customize the stacking order ... */ data pctdata; set pctdata; if type='Apple (iPhone)' then stack_order=1; else if type='RIM (blackberry)' then stack_order=2; else if type='Microsoft' then stack_order=3; else if type='Symbian' then stack_order=4; else if type='Palm' then stack_order=5; else if type='Other' then stack_order=6; else if type='Google (android)' then stack_order=7; else stack_order=.; run; /* User-defined format, so bar numbers print as item text */ proc sql; create table foo as select unique stack_order, type from pctdata; quit; run; data control; set foo (rename = ( stack_order=start type=label)); fmtname = 'myfmt'; type = 'N'; end = START; run; proc format lib=work cntlin=control; run; goptions device=png xpixels=950 ypixels=600; goptions noborder; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="U.S. Smartphone Market (iPhone, Android, Blackberry, other)") style=sasweb; goptions gunit=pct htitle=4.0 ftitle="albany amt/bold" htext=2.2 ftext="albany amt"; axis1 label=none order=(0 to 1 by .25) minor=none value=(height=2.5 font="albany amt/bold") offset=(0,0); axis2 offset=(1.2,1.2); axis3 offset=(0,0.08); legend1 label=none position=(right middle) across=1 shape=bar(.15in,.15in) order=descending /* new v9.3 feature - delete to run in pre-9.3 sas */ value=(justify=left height=2.8 font="albany amt/bold") offset=(0,0); title1 ls=1.5 move=(-10,+0) link="http://www.comscore.com/Insights/Press_Releases/" "Top 5 Smartphone Platforms in the U.S. by Month"; footnote1 link="http://www.comscore.com/Insights/Press_Releases/" j=c c=gray "Data Source: comScore MobiLens"; pattern1 v=s c=cxcb79c8; pattern2 v=s c=cxf7df54; pattern3 v=s c=cxef6b48; pattern4 v=s c=cx61a6e7; pattern5 v=s c=cxffa53d; pattern6 v=s c=white; pattern7 v=s c=cxa4ca39; proc gchart data=pctdata; format stack_order myfmt.; vbar month / discrete nozero type=sum sumvar=pctval group=year subgroup=stack_order raxis=axis1 maxis=axis2 gaxis=axis3 space=0 gspace=0.07 width=1.7 legend=legend1 ref=.25 .5 .75 1 cref=(gray33 gray33 gray33 gray33) wref=(1 2 1 1) coutline=gray88 noframe html=myhtml des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;