ods html close; %let gpath=C:\; %let w=2in; %let dpi=200; ods listing gpath="&gpath" image_dpi=&dpi; /*--Generate values between 0 and 100--*/ /*--Extract 10's as Stem and remainder as Leaf--*/ data stemLeaf; drop i; do i=1 to 20; value=50+floor(50*rannor(3)); stem=floor(value/10); leaf=value-stem*10; if value > 40 and value < 100 then output; end; run; /*--Sort--*/ proc sort data=stemleaf out=stemleafSort; by value; run; /*--Set x position for Leaves--*/ data stemleafGraph; set stemleafSort; by stem; zero=0; retain x 0; if first.stem then x=0; else x+1; run; /*--Using Scatter plot--*/ ods graphics / reset width=&w height=1in imagename='Stem_Leaf_Scatter'; title 'Stem and Leaf Plot'; proc sgplot data=stemleafGraph noautolegend noborder; scatter x=x y=stem / markerchar=leaf markercharattrs=(size=9) labelstrip; xaxis display=none offsetmin=0.05 max=10; yaxis display=(noticks nolabel) integer values=(4 to 9 by 1) reverse fitpolicy=none; run; /*--Using Text plot--*/ ods graphics / reset width=&w height=1in imagename='Stem_Leaf_Text'; title 'Stem and Leaf Plot'; proc sgplot data=stemleafGraph noautolegend noborder; text x=x y=stem text=leaf / textattrs=(size=9) strip; xaxis display=none offsetmin=0.05 max=10; yaxis display=(noticks nolabel) integer values=(4 to 9 by 1) reverse fitpolicy=none; run; /*--Generate values between 0 and 1000--*/ /*--Extract 100's as Stem and remainder as Leaf--*/ data stemLeaf_1K; do i=1 to 50; value=400+floor(400*rannor(3)); stem=floor(value/100); leaf=value-stem*100; if value > 0 and value < 1000 then output; end; run; /*--Sort--*/ proc sort data=stemLeaf_1K out=stemleaf_sort; by value; run; /*--Set x position for Leaves--*/ data stemleafGraph; set stemleaf_sort; by stem; zero=0; retain x 0; if first.stem then x=0; else x+1; run; /*--Using Text plot--*/ ods graphics / reset width=&w height=2in imagename='Stem_Leaf_1K'; title 'Stem and Leaf Plot'; proc sgplot data=stemleafGraph noautolegend noborder; format leaf z2.0; text x=x y=stem text=leaf / textattrs=(size=9) strip; xaxis display=none offsetmin=0.05 max=10; yaxis display=(noticks nolabel) integer values=(0 to 9 by 1) reverse fitpolicy=none; run; title;