%let name=calpie; filename odsout '.'; /* Trying to duplicate http://tsdsrv04.unx.sas.com:7777/sirius/sirts/fetch_attachment.pl/dataclockchart.ppt?trknum=us5742988&page_id=20020903_112156_693827 from customer call http://pockets.pc.sas.com/sirius/gsts/us/5742/us5742988.html */ data a; input year month $ value; cards; 1997 Jan 6 1997 Feb 9 1997 Mar 2 1997 Apr 3 1997 May 3 1997 Jun 6 1997 Jul 0 1997 Aug 0 1997 Sep 0 1997 Oct 0 1997 Nov 0 1997 Dec 0 1996 Jan 8 1996 Feb 5 1996 Mar 5 1996 Apr 2 1996 May 3 1996 Jun 5 1996 Jul 5 1996 Aug 9 1996 Sep 5 1996 Oct 5 1996 Nov 3 1996 Dec 3 1995 Jan 3 1995 Feb 5 1995 Mar 5 1995 Apr 5 1995 May 5 1995 Jun 5 1995 Jul 4 1995 Aug 5 1995 Sep 2 1995 Oct 1 1995 Nov 5 1995 Dec 2 1994 Jan 270 1994 Feb 5 1994 Mar 5 1994 Apr 5 1994 May 8 1994 Jun 3 1994 Jul 3 1994 Aug 5 1994 Sep 5 1994 Oct 5 1994 Nov 4 1994 Dec 5 1993 Jan 5 1993 Feb 8 1993 Mar 5 1993 Apr 5 1993 May 5 1993 Jun 9 1993 Jul 5 1993 Aug 5 1993 Sep 2 1993 Oct 2 1993 Nov 5 1993 Dec 7 1992 Jan 5 1992 Feb 5 1992 Mar 4 1992 Apr 150 1992 May 75 1992 Jun 275 1992 Jul 285 1992 Aug 80 1992 Sep 5 1992 Oct 5 1992 Nov 5 1992 Dec 5 1991 Jan 5 1991 Feb 5 1991 Mar 3 1991 Apr 5 1991 May 7 1991 Jun 5 1991 Jul 9 1991 Aug 9 1991 Sep 5 1991 Oct 2 1991 Nov 3 1991 Dec 5 1990 Jan 8 1990 Feb 2 1990 Mar 3 1990 Apr 4 1990 May 3 1990 Jun 1 1990 Jul 2 1990 Aug 2 1990 Sep 5 1990 Oct 8 1990 Nov 5 1990 Dec 5 ; run; proc sql; select max(year) into :max_year from a; select min(year) into :min_year from a; quit; run; /* Radius of maximum pie ring is this % of the screen */ %let radius=25; %let offset=5; /* offset for center of pie, to make room for title at top */ data pies; set a; length style function color $ 12; length html $200; xsys='3'; ysys='3'; hsys='3'; x=50; y=50-&offset; /* slightly down from center, to give room for 'title' above the chart */ function='PIE'; style='SOLID'; angle+((1/12)*360); /* start angle for this slice */ if month='Jan' then angle=0; rotate=((1/12)*360); /* each pie slice is 1/12th of a year */ /* the +3 gives extra room in the middle, for the hole */ size=(&radius*((year-&min_year+3)/(&max_year-&min_year))); /* maximum radius is &radius% of page */ color='gray'; if value >= 1 and value <= 62 then color='red'; if value >= 63 and value <= 124 then color='yellow'; if value >= 125 and value <= 186 then color='cx00ff00'; if value >= 187 and value <= 248 then color='cyan'; if value >= 249 then color='blue'; html='title='||quote( 'Date: '||trim(left(month))||' '||trim(left(year))||'0d'x|| 'earthquake count: '||trim(left(value)) ); output; run; /* Make a white hole/pie in the middle */ data hole; set a; length style function color $ 12; xsys='3'; ysys='3'; hsys='3'; x=50; y=50-&offset; function='PIE'; style='SOLID'; angle=0; line=0; rotate=360; size=(&radius*((2)/(&max_year-&min_year))); color='white'; html=''; output; run; /* Black outlines around the pie slices */ data outlines; set pies hole; style='EMPTY'; color='black'; line=1; run; /* annotate year labels */ /* subset data - only need 1 obsn per each year ... */ proc sql; create table years as select * from a where month='Mar'; quit; run; data years; set years; length style function color $ 12; length text $4; xsys='3'; ysys='3'; hsys='3'; x=50; y=50-&offset; function='LABEL'; /* Need a better equation - I just did something simple, and then tweaked the offset (2.6) until it looked ok */ y=50-&offset+(&radius*((year-&min_year+2.6)/(&max_year-&min_year))); color='black'; text=year; position='6'; /* lower/right position, in relation to x/y */ style='"arial"'; size=2.5; output; run; /* annotate month labels */ proc sql; create table months as select * from pies where year=&max_year; quit; run; data months; set months; length text $3; /* find a point that is half of the arc (rotate*.5) */ function='piexy'; angle=angle+rotate*.5; /* 5.6 times the radius/size of previous pie slice (previous slice was pie center) */ size=5.6; output; /* (XLAST, YLAST) cannot be used directly by text functions. Use CNTL2TXT to copy the coordinates in (XLAST, YLAST) to the XLSTT and YLSTT variables, which text functions can use. */ function='cntl2txt'; output; /* write the text label centered on the point stored in XLSTT and YLSTT */ function='label'; text=month; angle=0; rotate=0; color='black'; style='"arial/bo"'; size=3; x=.; y=.; position='5'; output; run; data title; length style function color $ 12; length text $50; xsys='3'; ysys='3'; hsys='3'; x=50; y=95; /* 90% from the bottom to the top of the page */ function='LABEL'; color='black'; text='Southern California Earthquakes'; position='5'; style='"arial/bo"'; size=5; output; run; data legend; length style function color $ 12; length text $20; xsys='3'; ysys='3'; hsys='3'; /* first, the text in the legend */ function='LABEL'; x=90; color='black'; style='"arial"'; position='6'; size=2.5; y=95; text='0'; output; y=90; text='1-62'; output; y=85; text='63-124'; output; y=80; text='125-186'; output; y=75; text='187-248'; output; y=70; text='249-~'; output; /* 'marker' character 'U' is a box - these are my color chips in legend */ x=88; style='marker'; position='5'; size=2.5; y=95-.5; text='U'; color='gray'; output; y=90-.5; text='U'; color='red'; output; y=85-.5; text='U'; color='yellow'; output; y=80-.5; text='U'; color='cx00ff00'; output; y=75-.5; text='U'; color='cyan'; output; y=70-.5; text='U'; color='blue'; output; run; data anno; set title pies outlines hole years months legend; run; GOPTIONS DEVICE=gif; goptions cback=white; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Southern California Earthquakes") gtitle nogfootnote style=d3d; goptions border; /* footnote link="http://pockets.pc.sas.com/sirius/gsts/us/5742/us5742988.html" "Based on scenario/request in this customer call from the CDC"; */ footnote "Based on a screen-capture sent in by a customer"; proc ganno annotate=anno des="" name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;