%let gpath='C:\'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi; /*--Compute BMI Curves--*/ data BMI; format Normal Over Obese 4.1; do Wt=60 to 360 by 20; Normal=sqrt(wt*703/18.5); Over=sqrt(wt*703/25); Obese=sqrt(wt*703/30); output; end; run; /*--Rotated BMI Labels--*/ data labels; Label='Underweight'; xl=120; yl=78; LabelAngle=60; output; Label='Normal'; xl=170; yl=78; LabelAngle=55; output; Label='Overweight'; xl=225; yl=78; LabelAngle=50; output; Label='Obese'; xl=275; yl=78; LabelAngle=45; output; run; /*--BMI Values--*/ data class; format BMI 4.1; set sashelp.class; if sex='M' then angle=30; else angle=-30; BMI=703*weight/(height*height); run; /*--Merge data--*/ data merged; merge class BMI labels; run; /*--Text Plot--*/ ods graphics / reset width=5in height=3in imagename='TextPlot'; title 'Height by age'; proc sgplot data=class; text x=age y=height text=name / group=sex textattrs=(size=12); keylegend / location=inside position=bottomright; xaxis grid; yaxis grid; run; /*--Text Plot angled text backlight--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='BMI_Curves'; title 'BMI Curves'; proc sgplot data=merged noautolegend; band x=wt lower=50 upper=normal / fillattrs=(color=yellow) transparency=0.8 outline fill; band x=wt lower=50 upper=over / fillattrs=(color=orange) transparency=0.8 outline fill; band x=wt lower=50 upper=obese / fillattrs=(color=red) transparency=0.8 outline fill; text x=xl y=yl text=label / rotate=labelangle position=left contributeoffsets=none; xaxis grid values=(80 to 360 by 40) offsetmax=0 label='Weight (lb)'; yaxis grid values=(54 to 78 by 3) label='Height (in)'; run; /*--Adjust BMI Labels--*/ data labels; Label='Underweight'; xl=120; yl=78; LabelAngle=60; output; Label='Normal'; xl=170; yl=78; LabelAngle=55; output; Label='Overweight'; xl=225; yl=78; LabelAngle=50; output; Label='Obese'; xl=275; yl=78; LabelAngle=45; output; run; data merged; merge class BMI labels; run; /*--Text Plot angled text backlight--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='BMI_Values_Group'; title 'BMI Curves with Values by Sex'; proc sgplot data=merged noautolegend; styleattrs datacolors=(lightred lightblue) datacontrastcolors=(red blue); band x=wt lower=50 upper=normal / fillattrs=(color=yellow) transparency=0.8 outline fill; band x=wt lower=50 upper=over / fillattrs=(color=orange) transparency=0.8 outline fill; band x=wt lower=50 upper=obese / fillattrs=(color=red) transparency=0.8 outline fill; text x=xl y=yl text=label / rotate=labelangle position=left contributeoffsets=none; scatter x=weight y=height / filledoutlinedmarkers group=sex datalabel=name dataskin=gloss markerattrs=(symbol=circlefilled size=10) datalabelattrs=(size=5 weight=bold); xaxis grid values=(80 to 360 by 40) offsetmax=0 label='Weight (lb)'; yaxis grid values=(54 to 78 by 3) label='Height (in)'; run; /*--Text Plot angled text backlight--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='BMI_Names'; title 'BMI Curves with Names by Sex'; proc sgplot data=merged noautolegend; styleattrs datacolors=(lightred lightblue) datacontrastcolors=(red blue); band x=wt lower=50 upper=normal / fillattrs=(color=yellow) transparency=0.8 outline fill; band x=wt lower=50 upper=over / fillattrs=(color=orange) transparency=0.8 outline fill; band x=wt lower=50 upper=obese / fillattrs=(color=red) transparency=0.8 outline fill; text x=xl y=yl text=label / rotate=labelangle position=left contributeoffsets=none; text x=weight y=height text=name / group=sex textattrs=(size=5) name='t'; xaxis grid values=(80 to 360 by 40) offsetmax=0 label='Weight (lb)'; yaxis grid values=(54 to 78 by 3) label='Height (in)'; keylegend 't' / location=inside position=bottomright title='Sex: '; run; /*--Size Response--*/ proc template; define statgraph TextPlot; begingraph; entrytitle 'Weight by Age and Height'; entryfootnote halign=left 'Font size for each name is proportional to weight'; layout overlay / xaxisopts=(griddisplay=on) yaxisopts=(griddisplay=on); textplot x=age y=height text=name/ sizeresponse=weight colorresponse=weight colormodel=(green yellow red) name='t' backlight=0.5; continuouslegend 't' / title='Weight'; endlayout; endgraph; end; run; /*--Size Response--*/ ods graphics / reset width=5in height=3in imagename='Size_Resp'; proc sgrender data=sashelp.class template=TextPlot; run;