%let gpath='C:\';
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
data products;
length Product Group Label $30;
format Profit Revenue dollar10.;
i=0;
do product='Chair', 'Desk', 'Table', 'Sofa', 'Lamp', 'Bed', 'SideTable', 'Armoire',
'Dresser', 'Mirror';
Revenue=20000*(abs(rannor(3))+1);
Profit=10000*(abs(rannor(3))+1);
Label=catx(' ', product, put(revenue, dollar10.));
if i <=4 then Group='Living';
else Group='Bedroom';
output;
i+1;
end;
run;
ods html;
proc print data=products(obs=5);
var product group revenue profit;
run;
ods html close;
data AreaBar;
set products;
retain x 0 id 0 delta 2000;
format x y dollar10.;
id=id+1; y=0; output;
y=profit; output;
x=x+revenue-delta; output;
y=0; output;
x=x+delta;
run;
ods html;
proc print data=areabar(obs=6);
var product group revenue profit id x y;
run;
ods html close;
/*--Simple Area Bar Chart--*/
ods graphics / reset width=5in height=3in imagename='AreaBar';
proc sgplot data=areabar;
title 'Revenue and Profit by Product';
polygon id=id x=x y=y / fill outline;
yaxis offsetmin=0 grid label='Profit';
xaxis label='Revenue';
run;
/*--Simple Area Bar Chart with Labels--*/
ods graphics / reset width=5in height=3in imagename='AreaBarLabel';
proc sgplot data=areabar;
title 'Revenue and Profit by Product';
polygon id=id x=x y=y / fill outline dataskin=gloss label=product;
yaxis offsetmin=0 grid label='Profit';
xaxis label='Revenue';
run;
/*--Simple Area Bar Chart with Top Labels--*/
ods graphics / reset width=5in height=3in imagename='AreaBarLabelTop';
proc sgplot data=areabar;
title 'Revenue and Profit by Product';
polygon id=id x=x y=y / fill outline dataskin=gloss label=product labelpos=ymax;
yaxis offsetmin=0 grid label='Profit';
xaxis label='Revenue';
run;
/*--Simple Area Bar Chart with Top Outside Labels--*/
ods graphics / reset width=5in height=3in imagename='AreaBarLabelTopOutsideBBox';
proc sgplot data=areabar;
title 'Revenue and Profit by Product';
polygon id=id x=x y=y / fill outline dataskin=gloss label=product
labelpos=ymax labelloc=outsidebbox;
yaxis offsetmin=0 grid label='Profit';
xaxis label='Revenue';
run;
/*--Simple Area Bar Chart with Rotated Labels--*/
ods graphics / reset width=5in height=3in imagename='AreaBarLabelTopRotate';
proc sgplot data=areabar;
title 'Revenue and Profit by Product';
polygon id=id x=x y=y / fill outline dataskin=gloss label=product
labelpos=ymax rotatelabel=vertical;
yaxis offsetmin=0 grid label='Profit';
xaxis label='Revenue';
run;
/*--Grouped Area Bar Chart with Rotated Labels--*/
ods graphics / reset width=5in height=3in imagename='AreaBarLabelGroup';
proc sgplot data=areabar;
title 'Revenue and Profit by Product and Group';
polygon id=id x=x y=y / fill outline dataskin=gloss label=product
labelpos=ymax rotatelabel=vertical group=group;
yaxis offsetmin=0 grid label='Profit';
xaxis label='Revenue';
keylegend / location=inside position=topleft;
run;
/*--Grouped Area Bar Chart with Rotated black Labels--*/
ods graphics / reset width=5in height=3in imagename='AreaBarLabelColor';
proc sgplot data=areabar;
title 'Revenue and Profit by Product and Group';
polygon id=id x=x y=y / fill outline dataskin=gloss label=label splitchar=' '
labelpos=ymax rotatelabel=vertical group=group labelattrs=(color=black);
yaxis offsetmin=0 grid label='Profit';
xaxis label='Revenue';
keylegend / location=inside position=topleft;
run;
/*--Grouped Area Bar Chart with compound Labels--*/
ods graphics / reset width=5in height=3in imagename='AreaBarLabelRevenue';
proc sgplot data=areabar;
title 'Revenue and Profit by Product and Group';
polygon id=id x=x y=y / fill outline dataskin=gloss label=label splitchar=' '
labelpos=ymax group=group labelattrs=(color=black) labelattrs=(size=5);
yaxis offsetmin=0 grid label='Profit';
xaxis label='Revenue';
keylegend / location=inside position=topleft;
run;
/*--Simple Example--*/
data poly;
input ID $1-2 Name $3-4 offset y label $;
datalines;
X A 0.0 0 foo
X B 0.0 1 foo
X C 0.0 1 foo
X D 0.0 0 foo
X . . foo
X A 0.5 0.25 foo
X B 0.0 0.75 foo
X C 0.0 0.75 foo
X C 0.0 0.25 foo
Y B 0.5 0.5 bar
Y C 0.0 3 bar
Y D 0.0 2 bar
;
ods html;
proc print data=poly;
run;
ods html close;
/*--Simple Example--*/
ods graphics / reset width=5in height=3in imagename='PolygonPlot';
proc sgplot data=poly;
polygon id=id x=name y=y / xoffset=offset
dataSkin=matte fillattrs=(transparency=0.5)
group=id fill outline name='foo';
keylegend / location=inside position=topleft;
run;