23
MASUG MASUG September 15, 2005 September 15, 2005

MASUG September 15, 2005. Agenda Guest Introductions John Boling – SAS inSchool Tim Garton – Health Forecasts Announcements Tips & Tricks

Embed Size (px)

Citation preview

Page 1: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

MASUGMASUG

September 15, 2005September 15, 2005

Page 2: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

AgendaAgenda

Guest IntroductionsGuest Introductions John Boling – SAS inSchoolJohn Boling – SAS inSchool Tim Garton – Health ForecastsTim Garton – Health Forecasts

AnnouncementsAnnouncements Tips & TricksTips & Tricks Member PresentationMember Presentation SAS inSchoolSAS inSchool

Page 3: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

AnnouncementsAnnouncements

and now a few words from Gordon and now a few words from Gordon Galey……..Galey……..

Page 4: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Annotating Graphs Is Simpler Annotating Graphs Is Simpler Than You ThinkThan You Think

(With An email Excursion)(With An email Excursion)

Walt SmithWalt Smith

FedEx ForecastingFedEx Forecasting

MASUG Sep 15, 2005MASUG Sep 15, 2005

Page 5: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Graphs can be powerful ways to draw a Graphs can be powerful ways to draw a picture of your data.picture of your data.

Key information can be “drawn” on the Key information can be “drawn” on the graph to make the graph tell even more graph to make the graph tell even more of the story.of the story.

A simple example:A simple example:

Page 6: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Do you see anything obvious?

Page 7: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

There seems to be “events” in this time There seems to be “events” in this time series – specifically a significant shift up series – specifically a significant shift up between Dec03 and Jun04 – and between Dec03 and Jun04 – and another shift down about Jul05another shift down about Jul05

Assuming the cause is known (in this Assuming the cause is known (in this case, a large account was won and lost), case, a large account was won and lost), this information can be added.this information can be added.

Page 8: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

This is more clear:

Page 9: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Why should I do this with SAS? I could Why should I do this with SAS? I could just import my data into Excel and build just import my data into Excel and build a graph in just a few clicks (well, OK, a graph in just a few clicks (well, OK, more than a few clicks).more than a few clicks).

What if you need to do it every month? What if you need to do it every month? Every week? Every day? For dozens – Every week? Every day? For dozens – hundreds of graphs? – Still want to use hundreds of graphs? – Still want to use Excel?Excel?

Page 10: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

First the code to produce the basic graphFirst the code to produce the basic graph

proc gplot data=mydata.random_ts;proc gplot data=mydata.random_ts; plot sales * date / frame plot sales * date / frame haxis = axis1 vaxis = axis2haxis = axis1 vaxis = axis2 cframe = cxeeeedd ;cframe = cxeeeedd ; format sales comma5.0;format sales comma5.0; format date monyy5.;format date monyy5.;run;run;

Page 11: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Then the options, symbol, and axis Then the options, symbol, and axis statements that will help dress it up.statements that will help dress it up.

options orientation = landscape;goptions reset = all device = gif gunit = pct ftitle = swissb htitle = 5 ftext = swiss htext = 3 cback = cxbbc4cf ;symbol1 color=black interpol=join value=dot height=2 width=3 line=1;%let haxis = '01jun2002'd '01dec2002'd '01jun2003'd '01dec2003'd;%let haxis = &haxis '01jun2004'd '01dec2004'd '01jun2005'd '01dec2005'd;%let haxis = &haxis '01jun2006'd;axis1 label=none minor=none order=( &haxis );axis2 label=none minor=none;title1 "Sales Region: Random";

Page 12: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Now for the annotations – Now for the annotations –

SAS/Graph procedures accept an “annotate” dataset SAS/Graph procedures accept an “annotate” dataset that contains the annotate information.that contains the annotate information.

Annotate information can be very simple or very Annotate information can be very simple or very complex according to your needs.complex according to your needs.

An annotate dataset is simply a dataset that has An annotate dataset is simply a dataset that has certain “annotate” variables in it.certain “annotate” variables in it.

The basic variables are the x,y coordinates to place The basic variables are the x,y coordinates to place the text (or object), the size, color, etc, and the the text (or object), the size, color, etc, and the function to perform (label, draw, etc)function to perform (label, draw, etc)

Page 13: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

The annotate data step codeThe annotate data step codedata anno; length color function style $8; length text $200; length x y 8; xsys = '2'; ysys = '2'; hsys = '5'; function = 'label'; set mydata.random_ts; if ( date = &event1 ) then do; x = date; y = sales + 150; size = 4; text = 'ABC Account'; style = 'swiss'; color = 'blue'; position = 'A'; output; y = sales + 75; size = 2; text = 'D'; style = 'marker'; position = 'B'; output; end;

if ( date = &event2 ) then do; x = date; y = sales - 150; size = 4; text = 'Lost Account'; style = 'swiss'; color = 'red'; position = 'E'; output; y = sales - 75; size = 2; text = 'C'; style = 'marker'; position = 'E'; output; end;run;

Page 14: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Variables xsys, ysys, hsys specify the Variables xsys, ysys, hsys specify the “coordinate system” for x, y values and sizes of “coordinate system” for x, y values and sizes of

things (like text)things (like text)

Page 15: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Simplified code using Simplified code using 3 annotate macros3 annotate macros

data anno; %avars %xyhsys(2,2,5) set mydata.random_ts; if ( date = &event1 ) then do; %alabel(date, sales+150 ,'ABC Account',blue,,,4,swiss,A) %alabel(date, sales+75 ,'D',,,,2,marker,B) end; if ( date = &event2 ) then do; %alabel(date, sales-150 ,'Lost Account',red,,,4,swiss,E) %alabel(date, sales-75 ,'C',,,,2,marker,E) end;run;

Page 16: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

The Annotate Dataset Has 4 ObsThe Annotate Dataset Has 4 Obs

f pf p u ou o n sn s c c s s ic c s s i o t t t x y h d a s to t t t x y h d a s tO l i y e s s s a l i iO l i y e s s s a l i ib o o l x y y y t e z ob o o l x y y y t e z os r n e t x y s s s e s e ns r n e t x y s s s e s e n

1 blue label swiss ABC Account 16162 5761.74 2 2 5 APR04 5611.74 4 A1 blue label swiss ABC Account 16162 5761.74 2 2 5 APR04 5611.74 4 A2 blue label marker D 16162 5686.74 2 2 5 APR04 5611.74 2 B2 blue label marker D 16162 5686.74 2 2 5 APR04 5611.74 2 B3 red label swiss Lost Account 16649 5634.84 2 2 5 AUG05 5784.84 4 E3 red label swiss Lost Account 16649 5634.84 2 2 5 AUG05 5784.84 4 E4 red label marker C 16649 5709.84 2 2 5 AUG05 5784.84 2 E4 red label marker C 16649 5709.84 2 2 5 AUG05 5784.84 2 E

Page 17: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Applying the annotate dataset Applying the annotate dataset is the easy partis the easy part

proc gplot data=mydata.random_ts; plot sales * date / frame haxis = axis1 vaxis = axis2 annotate = anno cframe = cxeeeedd ; format sales comma5.0; format date monyy5.;run;

Page 18: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Last, we want to send this graphLast, we want to send this graphin an email – using SASin an email – using SAS

%let mygraph = mygraph.gif;filename gsfile "&mygraph";goptions gsfname=gsfile gaccess=sasgastd;proc gplot data=mydata.random_ts;…run;filename dummy email;data _null_; file dummy to = ("[email protected]") subject = "Sales Region Report" attach = "&mygraph“ ; put 'Attached is the Sales Region Report.'; put 'If you have any questions feel free to call.';run;

SAS V9 Only

Page 19: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks
Page 20: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

Member PresentationMember Presentation

Robert Hall, Baptist Memorial Health Robert Hall, Baptist Memorial Health Care Corp.Care Corp.

Page 21: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks

SAS inSchoolSAS inSchool

John Boling, Director SAS inSchoolJohn Boling, Director SAS inSchool

Page 22: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks
Page 23: MASUG September 15, 2005. Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks