%let gpath='.'; %let dpi=200; ods html close; ods listing style=listing gpath=&gpath image_dpi=&dpi; /*--Data--*/ data PNL; format Date monname3. Profit percent5.1 Revenue dollar.; label Revenue='Revenue (Millions)'; do date='01Jan2015'd, '01Feb2015'd, '01Mar2015'd, '01Apr2015'd, '01May2015'd, '01Jun2015'd, '01Jul2015'd, '01Aug2015'd, '01Sep2015'd, '01Oct2015'd, '01Nov2015'd, '01Dec2015'd; Revenue=100*(1+ranuni(2)); Profit=(0.7- ranuni(2)); output; end; run; /*ods html;*/ /*proc print data=pnl(obs=5);run;*/ /*ods html close;*/ /*--Barline for Raw data--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='Bar_Line'; title 'Revenues and Profit by Month for 2014'; proc sgplot data=pnl; vbarparm category=date response=revenue / fillattrs=graphdata1 filltype=gradient name='a' baselineattrs=(thickness=0); series x=date y=profit / y2axis lineattrs=graphdata2(thickness=3); xaxis display=(nolabel); yaxis offsetmin=0; keylegend / linelength=24; run; /*--Barline with zero Equalization--*/ data _null_; retain revMax -1e6 revMin 1e6 prMax -1e6 prMin 1e6; set pnl end=last; revMax=max(revMax, revenue); revMin=min(revMin, revenue); prMax=max(prMax, profit); prMin=min(prMin, profit); if last then do; y1max=revMax; y1min=revMax*(prMin / prMax); call symput ("y1Max", revMax); call symput ("y1Min", y1min); end; run; /*%put &y1Max &y1Min;*/ /*--Barline for Zero Equalized data--*/ ods listing style=analysis; ods graphics / reset attrpriority=color width=5in height=3in imagename='Bar_Line_ZeroEq'; title 'Revenues and Profit by Month for 2014'; proc sgplot data=pnl; vbarparm category=date response=revenue / fillattrs=graphdata1 filltype=gradient name='a' baselineattrs=(thickness=0); series x=date y=profit / y2axis lineattrs=graphdata2(thickness=3); xaxis display=(nolabel); yaxis min=&y1Min max=&y1Max; keylegend / linelength=24; run; /*--Barline for Zero Equalized data and equal grids--*/ ods listing style=curve; ods graphics / reset attrpriority=color width=5in height=3in imagename='Bar_Line_ZeroEq_Grid'; title 'Revenues and Profit by Month for 2014'; proc sgplot data=pnl; vbarparm category=date response=revenue / fillattrs=(color=white) baselineattrs=(thickness=0); vbarparm category=date response=revenue / fillattrs=graphdata1 filltype=gradient name='a' baselineattrs=(thickness=0); series x=date y=profit / y2axis lineattrs=graphdata2(thickness=3) name='b'; xaxis display=(nolabel); yaxis values=(-70 to 210 by 70) grid; y2axis values=(-0.25 to 0.75 by 0.25); keylegend 'a' 'b' / linelength=24; run;