ods html close; %let gpath=C:\; %let w=5in; %let h=3in; %let dpi=200; ods listing gpath="&gpath" image_dpi=&dpi; /*--Generate some data--*/ data bars; drop i j a; length Name $6; a=0.99; do i=1 to 50; Actual=a*ranuni(1); Predict=Actual*(1+ranuni(1))/2; a=a**1.4; if a < 0.1 then a=0.1; do j=1 to 6; substr(Name,j)=byte(int(97+26*ranuni(2))); end; name=propcase(name); output; end; run; /*--Sort by descending value--*/ proc sort data=bars out=sorted; by descending actual; run; /*--Add sorted id number--*/ data bars2; format actual predict percent.; set sorted; id=_n_; run; /*--Display all bars--*/ ods graphics / reset width=&w height=&h imagename='Bars_All'; title 'Actual Values by Name'; proc sgplot data=bars2 noborder; vbar name / response=actual nostatlabel dataskin=pressed fillattrs=graphdata1; xaxis discreteorder=data display=(nolabel) valueattrs=(size=7); yaxis display=(noticks noline nolabel) grid; run; /*--Display first 8 bars--*/ ods graphics / reset width=&w height=&h imagename='Bars_1_8'; title 'Actual Values by Name'; proc sgplot data=bars2 noborder; vbar id / response=actual nostatlabel dataskin=pressed fillattrs=graphdata2; xaxistable name / nolabel valueattrs=(size=9); xaxis type=linear values=(1 to 20 by 1) valueshint min=1 max=7.95 display=(novalues nolabel); yaxis display=(noticks noline nolabel) grid; run; /*--Display first 8 bars--*/ ods graphics / reset width=&w height=&h imagename='VBar_Line_1_8'; title 'Actual and Predicted Values by Name'; proc sgplot data=bars2 noborder; vbar id / response=actual nostatlabel dataskin=pressed fillattrs=graphdata3 filltype=gradient; vline id / response=predict nostatlabel lineattrs=graphdata3(thickness=3 pattern=solid); xaxistable name / nolabel valueattrs=(size=9); xaxis type=linear values=(1 to 20 by 1) valueshint min=1 max=8.1 display=(novalues nolabel); yaxis display=(noticks noline nolabel) grid offsetmin=0; keylegend / position=topright location=inside linelength=20; run; /*--Display bars 3 - 10--*/ ods graphics / reset width=&w height=&h imagename='HBar_Line_1_10'; title 'Actual and Predicted Values by Name'; proc sgplot data=bars2 noborder noautolegend; hbar id / response=actual nostatlabel dataskin=pressed fillattrs=graphdata4; hline id / response=predict nostatlabel lineattrs=graphdata4(thickness=3 pattern=solid); yaxistable name / nolabel valueattrs=(size=9) position=left valuejustify=right; yaxis type=linear values=(1 to 20 by 1) valueshint min=1 max=10.3 display=(novalues nolabel); xaxis offsetmin=0 display=(nolabel); keylegend / position=bottomright location=inside linelength=20 across=1; run;