%let name=scen4; filename odsout '.'; goptions device=gif; goptions gunit=pct htitle=5 ftitle="arial/bo" htext=2.5 ftext="arial"; /* Revenue by region (rvr) */ PROC IMPORT DATAFILE= "scenario3.xls" DBMS=XLS OUT=rvr1 REPLACE; RANGE='Scenario3$A37:N37'; GETNAMES=NO; MIXED=NO; RUN; data rvr1 (drop=a b c d e f g h i j k l m n); set rvr1; F1=a; F2=b; F3=c; F4=d; F5=e; F6=f; F7=g; F8=h; F9=i; F10=j; F11=k; F12=l; F13=m; F14=n; run; data rvr1; set rvr1 (drop=f2); run; proc transpose data=rvr1 out=rvr1; by f1; run; data rvr1 (keep=region month sales); set rvr1; region=f1; sales=col1; month=0; month=(scan(_name_,1,'F')-2); run; PROC IMPORT DATAFILE= "scenario3.xls" DBMS=XLS OUT=rvr2 REPLACE; RANGE='Scenario3$A38:N38'; GETNAMES=NO; MIXED=NO; RUN; data rvr2 (drop=a b c d e f g h i j k l m n); set rvr2; F1=a; F2=b; F3=c; F4=d; F5=e; F6=f; F7=g; F8=h; F9=i; F10=j; F11=k; F12=l; F13=m; F14=n; run; data rvr2; set rvr2 (drop=f2); run; proc transpose data=rvr2 out=rvr2; by f1; run; data rvr2 (keep=region month sales); set rvr2; region=f1; sales=col1; month=0; month=(scan(_name_,1,'F')-2); run; PROC IMPORT DATAFILE= "scenario3.xls" DBMS=XLS OUT=rvr3 REPLACE; RANGE='Scenario3$A39:N39'; GETNAMES=NO; MIXED=NO; RUN; data rvr3 (drop=a b c d e f g h i j k l m n); set rvr3; F1=a; F2=b; F3=c; F4=d; F5=e; F6=f; F7=g; F8=h; F9=i; F10=j; F11=k; F12=l; F13=m; F14=n; run; data rvr3; set rvr3 (drop=f2); run; proc transpose data=rvr3 out=rvr3; by f1; run; data rvr3 (keep=region month sales); set rvr3; region=f1; sales=col1; month=0; month=(scan(_name_,1,'F')-2); run; PROC IMPORT DATAFILE= "scenario3.xls" DBMS=XLS OUT=rvr4 REPLACE; RANGE='Scenario3$A40:N40'; GETNAMES=NO; MIXED=NO; RUN; data rvr4 (drop=a b c d e f g h i j k l m n); set rvr4; F1=a; F2=b; F3=c; F4=d; F5=e; F6=f; F7=g; F8=h; F9=i; F10=j; F11=k; F12=l; F13=m; F14=n; run; data rvr4; set rvr4 (drop=f2); run; proc transpose data=rvr4 out=rvr4; by f1; run; data rvr4 (keep=region month sales); set rvr4; region=f1; sales=col1; month=0; month=(scan(_name_,1,'F')-2); run; PROC IMPORT DATAFILE= "scenario3.xls" DBMS=XLS OUT=rvr5 REPLACE; RANGE='Scenario3$A41:N41'; GETNAMES=NO; MIXED=NO; RUN; data rvr5 (drop=a b c d e f g h i j k l m n); set rvr5; F1=a; F2=b; F3=c; F4=d; F5=e; F6=f; F7=g; F8=h; F9=i; F10=j; F11=k; F12=l; F13=m; F14=n; run; data rvr5; set rvr5 (drop=f2); run; proc transpose data=rvr5 out=rvr5; by f1; run; data rvr5 (keep=region month sales); set rvr5; region=f1; sales=col1; month=0; month=(scan(_name_,1,'F')-2); run; data rvr; set rvr1 rvr2 rvr3 rvr4 rvr5; /* if month in (1 2 3) then quarter='Q1'; if month in (4 5 6) then quarter='Q2'; if month in (7 8 9) then quarter='Q3'; if month in (10 11 12) then quarter='Q4'; */ run; proc sql; create table rvr_sum as select unique region, sum(sales) as region_sales from rvr group by region; quit; run; data rvr_sum; set rvr_sum; length product $ 20; if region eq 'North America' then do; product='Cabernet'; sales=.1826*region_sales; output; product='Zinfandel'; sales=.083534*region_sales; output; product='Merlot'; sales=.129248*region_sales; output; product='Chardonnay'; sales=.494798*region_sales; output; product='Sauvignon Blanc'; sales=.1098*region_sales; output; end; else if region eq 'Europe' then do; product='Cabernet'; sales=.0826*region_sales; output; product='Zinfandel'; sales=.083534*region_sales; output; product='Merlot'; sales=.149248*region_sales; output; product='Chardonnay'; sales=.574798*region_sales; output; product='Sauvignon Blanc'; sales=.1098*region_sales; output; end; else if region eq 'South America' then do; product='Cabernet'; sales=.1826*region_sales; output; product='Zinfandel'; sales=.083534*region_sales; output; product='Merlot'; sales=.249248*region_sales; output; product='Chardonnay'; sales=.274798*region_sales; output; product='Sauvignon Blanc'; sales=.1098*region_sales; output; end; else if region eq 'Middle East' then do; product='Cabernet'; sales=.0826*region_sales; output; product='Zinfandel'; sales=.083534*region_sales; output; product='Merlot'; sales=.019248*region_sales; output; product='Chardonnay'; sales=.374798*region_sales; output; product='Sauvignon Blanc'; sales=.4398*region_sales; output; end; else if region eq 'Asia' then do; product='Cabernet'; sales=.0426*region_sales; output; product='Zinfandel'; sales=.383534*region_sales; output; product='Merlot'; sales=.189248*region_sales; output; product='Chardonnay'; sales=.174798*region_sales; output; product='Sauvignon Blanc'; sales=.2098*region_sales; output; end; run; data rvr_sum; set rvr_sum; length myhtml $ 200; myhtml ='title='||quote( 'Region: '|| trim(left(region)) ||'0D'x|| 'Wine: '|| trim(left(product)) ||'0D'x|| 'Sales: '|| trim(left(put(sales,dollar20.2))) ) ||' '|| 'href="scenario3.xls"'; run; /* Creat the sas/graph map data set */ libname here '.'; /* proc datasets lib=here nolist nowarn; delete scen4map; run; %include 'treemap_inc.sas'; %treemac(rvr_sum,region,product,sales,here.scen4map,0,0,150,100); */ %include 'treeanno_inc.sas'; %treelabel(here.scen4map,region,cyan,annofram,annolabel); data annofram; set annofram; color='cx5c3317'; size=.6; run; data annolabel; set annolabel; size=3; style="swissbe"; color='cx5c3317'; output; /* style="swissbe"; color='grayee'; output; color='white'; cbox='cx5c3317'; */ run; data tree_anno; set annofram annolabel; run; /* */ legend1 position=(top) offset=(-34,0) shape=bar(2.8,3.3) label=none across=1 value=(font="arial"); goptions ctext=cx5c3317; data titlanno; length text $ 100; xsys='3'; ysys='3'; hsys='3'; function='label'; position='5'; color="cx5c3317"; x=62; y=93; size=4.7; style='"arial/bo"'; text="Wine Sales by Region during 2004"; output; x=62; y=87; size=3.2; style='"arial/bo"'; text="color of box represents wine type"; output; x=62; y=83; size=3.2; style='"arial/bo"'; text="size of box represents sales"; output; run; GOPTIONS DEVICE=gif; goptions display; goptions xpixels=880 ypixels=720; goptions cback=grayee; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Scenario 4 (Open Class)") style=minimal gtitle gfootnote ; goptions noborder; title " "; /* title "Wine Sales by Region in 2004"; title2 "Color=Wine, Size=Sales"; */ /* Cabernet - maroon, ruby red, Chardonnay - straw-colored, pale straw yellow, light gold, greenish-yellow Merlot Sauvignan Blanc - light straw in color, brilliant lemon-lime, pale wheat, golden yellow, greenish yellow to straw yellow Zinfandel - Red Wine, medium ruby, deep purple, dark ruby, brilliant ruby */ pattern1 v=s c=cxff3030; pattern2 v=s c=cxf7fcb9; pattern3 v=s c=cxffc1c1; pattern4 v=s c=cxdbdb70; pattern5 v=s c=cxb6316c; proc gmap data=rvr_sum map=here.scen4map anno=tree_anno; id region product; choro product / coutline=white woutline=1 legend=legend1 html=myhtml anno=titlanno des="" name="&name"; run; /* */ /* proc print data=rvr_sum; by region; sum sales; run; */ quit; ODS HTML CLOSE; ODS LISTING;