data one; input trt_group time subject results; datalines; 1 2 100 20 1 4 100 30 1 6 100 35 1 8 100 50 1 2 200 40 1 4 200 25 1 6 200 40 1 8 200 30 1 2 300 25 1 4 300 40 1 6 300 45 1 8 300 55 2 2 400 15 2 4 400 35 2 6 400 50 2 8 400 45 2 2 500 35 2 4 500 35 2 6 500 20 2 8 500 35 ; run; proc template; define statgraph grouping; begingraph; entrytitle 'Study Results by Treatment Group'; layout overlay; seriesplot x=time y=results/ group=subject linecolorgroup=trt_group name='grouping'; discretelegend 'grouping' / type=linecolor; endlayout; endgraph; end; proc sgrender data=one template=grouping; run; proc sgplot data=one; title 'Study Results by Treatment Group'; series x=time y=results / group=subject grouplc=trt_group name='grouping'; keylegend 'grouping' / type=linecolor; run;