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

%let mc2path=\\l72586.na.sas.com\public\VAST_2011\MC_2_Core_Data\;

libname mydata "&mc2path";

goptions device=png;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" (title='IEEE VAST Challenge 2011 - mini-challenge 2') style=statistical; 
goptions noborder;
goptions cback=white;
goptions gunit=pct htitle=16pt htext=11pt ftitle="arial/bold" ftext="arial";

axis1 label=('Count') minor=none offset=(0,0);
axis2 /* label=none */ value=(height=8pt);
axis3 /* label=none */;

data foo; set mydata.ids (where=(violation^=''));
length myhtml $100;
myhtml='href='||quote('#_'||trim(left(destination_ip)))||
 ' title='||quote(trim(left(destination_ip)));
run;

legend1 shape=bar(.15in,.15in) position=(top center inside) offset=(-10,0);

title1 j=l ls=1.5 " Intrusion Detection System (IDS) hourly summary - by Destination IP";
title2 j=l " mouse-over bar segments to see IP address";
title3 j=l " click bar segments to drilldown to details";
goptions xpixels=1500 ypixels=600;
proc gchart data=foo;
vbar hour / discrete type=freq nozero
 group=date
 subgroup=destination_ip
 legend=legend1
 raxis=axis1
 maxis=axis2 
 gaxis=axis3
 html=myhtml
 des='' name="&name";
run;

proc sql noprint;
create table summary as
select unique destination_ip, date, violation, count(*) as count
from foo
group by destination_ip, date, violation
order by destination_ip, date, violation;
quit; run;

%macro do_table(destination_ip);
ods html anchor="_&destination_ip";
data tempdata; set summary (where=(destination_ip="&destination_ip")); run;
title "Intrusion Detection summary for " color=red "#byval(destination_ip)";
options nocenter nobyline;
proc print data=tempdata noobs;
by destination_ip;
var date count violation;
run;
%mend do_table;

/* Loop through, and make a plot for each manufacturer */
proc sql noprint;
create table loopdata as
select unique destination_ip
from summary;
quit; run;
data _null_; set loopdata;
   call execute('%do_table('|| destination_ip ||');');
run;


quit;
ODS HTML CLOSE;
ODS LISTING;

