%let gpath='C:\'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi; /*--Data Set SeriesGroup--*/ data SeriesGroup; drop i; length Class $6; format Date monname3.; do i=0 to 334 by 10; date='01jan2009'd+i; Drug='A'; Value = 16+ 3*sin(i/90+0.5) + 1*sin(3*i/90+0.7); Class='NSAID'; Company='XX'; output; Drug='B'; Value = 10+ 3*sin(i/90+0.5) + 1*cos(3*i/90+0.7); Class='NSAID'; Company='LL'; output; Drug='C'; Value = 10+ 3*cos(i/90+0.5) + 1*sin(3*i/90+0.7); Class='Opioid'; Company='XX'; output; Drug='D'; Value = 20+ 3*cos(i/90+0.5) + 2*sin(3*i/90+0.7); Class='Opioid'; Company='LL'; output; end; run; proc sort data=SeriesGroup out=SeriesGroupSorted; by drug; run; /*--Create drug label for each curve at every 5th value--*/ data SeriesGroupLabel; set SeriesGroupSorted; if mod(_n_, 5) = 1 then do; Label=Drug; ValueL=Value; end; run; /*--Standard Series Plot--*/ proc template; define statgraph Series; begingraph / subpixel=on; entrytitle 'Values by Date and Treatment'; layout overlay / xaxisopts=(display=(ticks tickvalues) timeopts=(tickvalueformat=data)) yaxisopts=(griddisplay=on); seriesplot x=date y=value / group=drug name='a' lineattrs=(thickness=2) smoothconnect=true; discretelegend 'a' / title='Drug:'; endlayout; endgraph; end; run; /*--Standard Series Plot--*/ ods graphics / reset width=5in height=3in imagename='Series_94'; proc sgrender data=SeriesGroup template=Series; run; /*--Standard Series Plot with inline labels--*/ proc template; define statgraph SeriesLabel; begingraph / subpixel=on; entrytitle 'Values by Date and Treatment'; layout overlay / xaxisopts=(display=(ticks tickvalues) timeopts=(tickvalueformat=data)) yaxisopts=(griddisplay=on); seriesplot x=date y=value / group=drug name='a' lineattrs=(thickness=2) smoothconnect=true; scatterplot x=date y=valueL / group=drug markerattrs=(symbol=circlefilled color=white size=10); scatterplot x=date y=valueL / group=drug markercharacter=label; discretelegend 'a' / title='Drug:' itemsize=(linelength=15px) location=inside across=1 halign=right valign=top; endlayout; endgraph; end; run; /*--Standard Series Plot with inline labels--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='SeriesLabel_94'; proc sgrender data=SeriesGroupLabel template=SeriesLabel; run; /*--Series Plot with color group--*/ proc template; define statgraph SeriesLineColorGroup; begingraph / subpixel=on; entrytitle 'Values by Date, Treatment and Class'; layout overlay / xaxisopts=(display=(ticks tickvalues) timeopts=(tickvalueformat=data)) yaxisopts=(griddisplay=on); seriesplot x=date y=value / group=drug name='a' lineattrs=(thickness=2) smoothconnect=true linecolorgroup=class; scatterplot x=date y=valueL / group=drug markerattrs=(symbol=circlefilled color=white size=10); scatterplot x=date y=valueL / group=drug markercharacter=label markercharacterattrs=graphdatatext; discretelegend 'a' / title='Drug Class:' type=linecolor location=inside across=1 halign=right valign=top; endlayout; endgraph; end; run; /*--Series Plot with color group--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='SeriesLineColorGroup_94'; proc sgrender data=SeriesGroupLabel template=SeriesLineColorGroup; run; /*--Series Plot with Line Color Group and Line Pattern Group--*/ proc template; define statgraph SeriesLineColorPatternGroup; begingraph / subpixel=on; entrytitle 'Values by Date, Treatment, Class and Company'; layout overlay / xaxisopts=(display=(ticks tickvalues) timeopts=(tickvalueformat=data)) yaxisopts=(griddisplay=on); seriesplot x=date y=value / group=drug name='a' lineattrs=(thickness=2) smoothconnect=true linecolorgroup=class linepatterngroup=company; scatterplot x=date y=valueL / group=drug markerattrs=(symbol=circlefilled color=white size=10); scatterplot x=date y=valueL / group=drug markercharacter=label markercharacterattrs=graphdatatext; layout gridded / halign=right valign=top columns=2 columngutter=5; discretelegend 'a' / title='Drug Class' type=linecolor location=inside across=1 halign=right valign=top; discretelegend 'a' / title='Company' type=linepattern location=inside across=1 halign=right valign=top itemsize=(linelength=30); endlayout; endlayout; endgraph; end; run; /*--Series Plot with Line Color Group and Line Pattern Group--*/ ods graphics / reset attrpriority=color width=5in height=3in imagename='SeriesLineColorPatternGroup_94'; proc sgrender data=SeriesGroupLabel template=SeriesLineColorPatternGroup; run; /*--Icon--*/ proc template; define statgraph MultiGroupIcon; begingraph / subpixel=on; entrytitle 'Values by Date, Trt, Class and Company'; layout overlay / xaxisopts=(display=(ticks tickvalues) timeopts=(tickvalueformat=data)) yaxisopts=(griddisplay=on); seriesplot x=date y=value / group=drug name='a' lineattrs=(thickness=2) smoothconnect=true linecolorgroup=class linepatterngroup=company; scatterplot x=date y=valueL / group=drug markerattrs=(symbol=circlefilled color=white size=10); scatterplot x=date y=valueL / group=drug markercharacter=label markercharacterattrs=graphdatatext; layout gridded / halign=right valign=top columns=2 columngutter=5; discretelegend 'a' / title='Drug Class' type=linecolor location=inside across=1 halign=right valign=top valueattrs=(size=8) titleattrs=(size=8); discretelegend 'a' / title='Company' type=linepattern location=inside across=1 halign=right valign=top itemsize=(linelength=30) valueattrs=(size=8) titleattrs=(size=8); endlayout; endlayout; endgraph; end; run; /*--Icon--*/ ods listing image_dpi=100; ods graphics / reset width=2.7in height=1.8in imagename='MultiGroup_Icon'; proc sgrender data=SeriesGroupLabel template=MultiGroupIcon; run;