%let gpath='C:\'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi; /*--Data for windows releases by date--*/ data Windows; input Date date9. Windows $11-16; format date date9.; label Windows = "Windows Release" ; datalines ; 01jun1990 3.0 01sep1995 95 01jul1998 98 01mar2000 2000 01nov2001 XP 01Feb2007 Vista 01Nov2009 Win7 01Nov2012 Win8 01Nov2014 Win8 ; run ; /*ods html;*/ /*proc print;run;*/ /*ods html close;*/ /*--Data for windows releases by date--*/ data WindowsRepeat; input Date date9. Windows $11-16 WinMiss $21-26; format date date9.; label Windows = "Windows Release" ; datalines ; 01jun1990 3.0 3.0 01jun1991 3.0 01jun1992 3.0 01jun1993 3.0 01jun1994 3.0 01sep1995 95 95 01sep1996 95 01sep1997 95 01jul1998 98 01jul1999 98 01mar2000 2000 2000 01nov2001 XP XP 01nov2002 XP 01nov2003 XP 01nov2004 XP 01nov2005 XP 01nov2006 XP 01Feb2007 Vista Vista 01Feb2008 Vista 01Nov2009 Win7 Win7 01Nov2010 Win7 01Nov2011 Win7 01Nov2012 Win8 Win8 01Nov2015 Win8 ; run ; /*ods html;*/ /*proc print data=WindowsRepeat(obs=10);run;*/ /*ods html close;*/ /*--Basic BlockPlot--*/ proc template; define statgraph Block; dynamic _display _type; begingraph; entrytitle 'Windows OS Releases'; layout overlay / xaxisopts=(timeopts=(minorticks=true)); blockplot x=date block=windows / display=_display valuehalign=center filltype=_type; endlayout; endgraph; end; run; /*--Basic BlockPlot--*/ ods graphics / reset width=5in height=3in imagename='Block'; proc sgrender data=Windows template=Block; run; /*--Block plot with block Values--*/ ods graphics / reset width=5in height=3in imagename='BlockValues'; proc sgrender data=Windows template=Block; dynamic _display='fill values'; run; /*--Block Values Alternate colors--*/ ods graphics / reset width=5in height=3in imagename='BlockValuesAlt'; proc sgrender data=Windows template=Block; dynamic _display='fill values' _type='Alternate'; run; /*--Block plot with Attributes--*/ proc template; define statgraph BlockAttrs; dynamic _color _trans; begingraph; entrytitle 'Windows OS Releases'; layout overlay / xaxisopts=(timeopts=(minorticks=true)); blockplot x=date block=windows / display=(fill values) valuehalign=center valuevalign=top filltype=alternate altfillattrs=(transparency=_trans) fillattrs=(color=_color) extendblockonmissing=true; endlayout; endgraph; end; run; /*--Block plot with Attributes--*/ ods graphics / reset width=5in height=3in imagename='BlockValuesAttrs'; proc sgrender data=WindowsRepeat template=BlockAttrs; dynamic _color='pink'; run; /*--Block Attrs Trans--*/ ods graphics / reset width=5in height=3in imagename='BlockValuesAttrsTrans'; proc sgrender data=Windows template=BlockAttrs; dynamic _color='pink' _trans=1; run; /*--Get data for microsoft--*/ proc sort data=sashelp.stocks(where=(stock='Microsoft')) out=MS; by date; run; /*--Merge Stock and release data by date--*/ data Series; keep Date Close Windows; merge ms Windows; by date; run; ods html; proc print data=Series(obs=50);run; ods html close; /*--Block and Series Overlay plot--*/ proc template; define statgraph BlockStock; dynamic _color _trans; begingraph; entrytitle 'Microsoft Stock Price with Windows OS Releases'; layout overlay / xaxisopts=(timeopts=(minorticks=true) display=(ticks tickvalues)); blockplot x=date block=windows / display=(fill values) valuehalign=center valuevalign=top filltype=alternate altfillattrs=(color=_color transparency=_trans) extendblockonmissing=true; seriesplot x=date y=close / lineattrs=graphfit; endlayout; endgraph; end; run; /*--Block and Stock--*/ ods graphics / reset width=5in height=3in imagename='BlockStock'; proc sgrender data=Series (where=(date < '01apr2005'd)) template=BlockStock; dynamic _color='white'; run; /*--Data with Multi var--*/ data WindowsMac; input Date date9. Windows $11-16 Mac $21-26; format date date9.; datalines ; 01jun1990 3.0 01May1991 OS7 01sep1995 95 01Aug1997 OS8 01jul1998 98 01Aug1999 OS9 01mar2000 2000 01Apr2001 OSX 01nov2001 XP 01Feb2007 Vista 01Nov2009 Win7 01Nov2012 Win8 01Nov2014 Win8 ; run ; ods html; proc print data=WindowsMac(obs=10);run; ods html close; /*--Block plot with Inner Margin--*/ proc template; define statgraph BlockInner; dynamic _color _trans; begingraph; entrytitle 'Windows and Mac OS Releases'; layout overlay / xaxisopts=(timeopts=(minorticks=true)); innermargin; blockplot x=date block=windows / display=(fill values label) valuehalign=center valuevalign=top filltype=alternate altfillattrs=(color=_color) fillattrs=graphdata1 extendblockonmissing=true valueattrs=(size=7); blockplot x=date block=mac / display=(fill values label) valuehalign=center valuevalign=top filltype=alternate altfillattrs=(color=_color) fillattrs=graphdata2 extendblockonmissing=true valueattrs=(size=7); endinnermargin; endlayout; endgraph; end; run; /*--Block plot with Inner Margin--*/ ods graphics / reset width=5in height=3in imagename='BlockInner'; proc sgrender data=WindowsMac template=BlockInner; dynamic _color='white'; run; /*--Block plot with Group data--*/ data blockGroup; set WindowsMac; keep Date Group Rel; Group='Win'; Rel=windows; output; Group='Mac'; Rel=mac; output; run; ods html; proc print data=blockGroup(obs=10);run; ods html close; /*--Group Block plot--*/ proc template; define statgraph BlockClass; dynamic _color _trans; begingraph; entrytitle 'Windows and Mac OS Releases'; layout overlay / xaxisopts=(timeopts=(minorticks=true)); blockplot x=date block=rel / class=group display=(fill values outline) valuehalign=center valuevalign=top includemissingclass=false filltype=alternate altfillattrs=(color=_color) extendblockonmissing=true valueattrs=(size=7); endlayout; endgraph; end; run; /*--Group Block plot--*/ ods graphics / reset width=5in height=3in imagename='BlockClass'; proc sgrender data=blockGroup template=BlockClass; dynamic _color='white'; run; /*--Merge Stock and multi column by date--*/ data SeriesMulti; keep Date Close Windows Mac; merge ms windowsmac; by date; run; proc print;run; /*--Convert to Group data--*/ data SeriesBlockGroup; set SeriesMulti; keep Date Close Group Rel; Group='Win'; Rel=windows; output; Group='Mac'; Rel=mac; output; run; proc print;run; /*--Group data with series--*/ proc template; define statgraph BlockClassSeries; dynamic _color _trans; begingraph; entrytitle 'Microsoft Stock Price with OS Releases'; layout overlay / xaxisopts=(timeopts=(minorticks=true) display=(ticks tickvalues)); blockplot x=date block=rel / class=group display=(fill values outline) valuehalign=center valuevalign=top includemissingclass=false filltype=alternate altfillattrs=(color=_color) outlineattrs=(color=gray) extendblockonmissing=true valueattrs=(size=7); seriesplot x=date y=close / lineattrs=graphfit; endlayout; endgraph; end; run; /*--Block Attrs--*/ ods graphics / reset width=5in height=3in imagename='BlockClassSeries'; proc sgrender data=SeriesBlockGroup(where=(date < '01apr2005'd)) template=BlockClassSeries; dynamic _color='white'; run; /*--Merge Stock and release data by date--*/ data SeriesGrp; keep Date Group Rel Close; merge ms blockGroup; by date; run; proc print;run; /*--Group data with series--*/ proc template; define statgraph BlockClassSeries2; dynamic _color _trans; begingraph; entrytitle 'Microsoft Stock Price with OS Releases'; layout overlay / xaxisopts=(timeopts=(minorticks=true) display=(ticks tickvalues)); blockplot x=date block=rel / class=group display=(fill values outline) valuehalign=center valuevalign=top includemissingclass=false filltype=alternate altfillattrs=(color=_color) outlineattrs=(color=gray) extendblockonmissing=true valueattrs=(size=7); seriesplot x=date y=close / lineattrs=graphfit; endlayout; endgraph; end; run; /*--Block Attrs--*/ ods graphics / reset width=5in height=3in imagename='BlockClassSeries2'; proc sgrender data=SeriesGrp(where=(date < '01apr2005'd)) template=BlockClassSeries2; dynamic _color='white'; run;