%let gpath='C:\';
%let dpi=100;
ods html close;
ods listing image_dpi=&dpi gpath=&gpath;
/*--Multi column data--*/
data testCols;
length week $ 2;
format A B C D E F percentn10.2 ;
format Sum 5.0;
input week Sum A B C D E F;
datalines;
18 5842 0.21 0.34 0.13 0.15 0.02 0.11
19 8501 0.11 0.14 0.23 0.25 0.32 0.21
20 7007 0.21 0.36 0.13 0.15 0.05 0.11
;
/*--Grouped data--*/
data test;
length week $ 2 operation $ 2;
format percent percentn10.2 ;
input week operation percent sum_week;
datalines;
18 A 0.21 5842
18 B 0.34 .
18 C 0.13 .
18 D 0.15 .
18 E 0.02 .
18 F 0.11 .
19 A 0.11 8501
19 B 0.14 .
19 C 0.23 .
19 D 0.25 .
19 E 0.32 .
19 F 0.21 .
20 A 0.21 7007
20 B 0.36 .
20 C 0.13 .
20 D 0.15 .
20 E 0.05 .
20 F 0.11 .
;
run;
proc print;run;
/*--Bar and multi Line--*/
ods graphics / reset width=5in height=3in imagename='BarLineCols1';
proc sgplot data=testcols;
title 'Sum and Percent by Week and Operation';
vbar week / response=sum fillattrs=graphdatadefault nostatlabel;
vline week / response=A lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=B lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=C lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=D lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=E lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=F lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
xaxis display=(nolabel);
yaxis offsetmin=0 display=(nolabel) ;
y2axis offsetmin=0 display=(nolabel);
run;
/*--Bar and multi Line with grid--*/
ods graphics / reset width=5in height=3in imagename='BarLineCols2';
proc sgplot data=testcols;
title 'Sum and Percent by Week and Operation';
vbar week / response=sum fillattrs=graphdatadefault nostatlabel transparency=0.2;
vline week / response=A lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=B lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=C lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=D lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=E lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
vline week / response=F lineattrs=(thickness=5 pattern=solid) nostatlabel y2axis;
xaxis display=(nolabel);
yaxis offsetmin=0 offsetmax=0.1 values=(0 to 8000 by 2000) display=(nolabel) grid;
y2axis offsetmin=0 offsetmax=0.1 values=(0 to 0.4 by 0.1) display=(nolabel);
run;
/*--Grouped Bar Line with skins and curve labels--*/
ods graphics / reset width=5in height=3in imagename='BarLineGrp';
proc sgplot data=test noautolegend;
title 'Sum and Percent by Week and Operation';
vbar week / group=operation response=sum_week fillattrs=graphdatadefault nostatlabel
transparency=0.2 dataskin=gloss;
vline week / group=operation response=percent lineattrs=(thickness=5 pattern=solid) y2axis
nostatlabel name='a' curvelabel;
xaxis display=(nolabel);
yaxis offsetmin=0 offsetmax=0.1 values=(0 to 8000 by 2000) display=(nolabel) grid;
y2axis offsetmin=0 offsetmax=0.1 values=(0 to 0.4 by 0.1) display=(nolabel);
run;