%let name=fm;
filename odsout '.';

/*
In this example, I try to use SAS/Graph to do some animated bubble plots,
similar to what JMP does.

Here's where I got my data:

Data from the JMP webcast, where they plotted sales*advertising, and
sized the bubbles by payroll, and animated over time (Wes Rehm)...
   \\L9880\public\jmp\fm_extract_to_sas_visual_bi.sas7bdat (ok to use)
*/

libname mydata '.';

%let dataset=fm_extract_to_sas_visual_bi;
%let yvar=operating_profit;
%let xvar=operating_expense;
%let colorvar=region_name;
%let colorvar=organization_name;


proc sql;
 create table plotdata as
 select * 
 from mydata.&dataset
 where (date ne .)
 order by date;
quit; run;

proc sql;
 create table annodate as
 select unique date
 from plotdata
 where (date ne .)
 order by date;
quit; run;

data plotdata; set plotdata;
format date monyy7.;
format &yvar dollar12.0;
format &xvar dollar12.0;
run;


data annodate; set annodate;
xsys='1'; ysys='1'; when='a';
x=83; y=89; 
function='label'; position='5'; style=''; color='gray'; 
text=put(date,monyy7.); output;
run;


goptions xpixels=900 ypixels=600 hsize= vsize=;
goptions cback=white;
goptions noborder;

options dev=sasprtc printerpath=gif animduration=.3 animloop=0
 animoverlay=no animate=start center;

ods listing close;
ods html path=odsout body="&name..htm"
 (title="FM Data Animation (SAS/Graph gifanim)")
 style=htmlblue;

goptions gunit=pct htitle=4 htext=3 ftitle="albany amt/bold" ftext="albany amt";

options nobyline;
title1 ls=1.5 "Financial Management (FM) Results";

proc gslide des='' name="&name";
run;

symbol font="wingdings 2" v='98'x h=4.5 repeat=1000;

axis1 color=graycc value=(color=gray) label=(color=black) order=(-50000000 to 150000000 by 50000000) minor=none offset=(0,0);
axis2 color=graycc value=(color=gray) label=(color=black) order=(0 to 75000000 by 25000000) minor=none offset=(0,0);

legend1 position=(right middle) across=1 label=none repeat=1;
/* repeat= is a new v9.2 feature ... delete it if you want this code to work in v9.1.3 */
 
proc gplot data=plotdata;
by date;
plot &yvar*&xvar=&colorvar /
 anno=annodate
 vaxis=axis1 haxis=axis2
 vref=(0 50000000 100000000 150000000) 
 cvref=(black graycc graycc graycc)
 autohref chref=graycc
 legend=legend1 noframe
 des='' name="&name";
run;

quit;
ods html close;
ods listing;
