%let name=mc2b;
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=minimal; 
goptions noborder;
goptions cback=white;
goptions gunit=pct htitle=16pt htext=11pt ftitle="arial/bold" ftext="arial";

legend1 label=none shape=bar(.15in,.15in);

axis1 label=none order=(0 to 150 by 50) minor=none;

pattern1 v=s c=cxEE3B3B;  /* red */
pattern2 v=s c=cxFFA812;  /* orange */

title ls=1.5 "Nessus Report: Security Holes & Warnings";
title2 ls=1.3 "(click bars to see details)";

goptions xpixels=800 ypixels=450;

data foo; set mydata.nessus (where=(severity^='' and severity^='Security Note'));
short_description=substr(description,15,index(description,'Description')-19);
short_description=tranwrd(short_description,"\n"," ");
myhtml='href='||quote('#'||'_'||trim(left(ip_address)));
run;
proc sql noprint;
create table foo as
select unique ip_address, severity, port, short_description, myhtml
from foo
order by ip_address;
quit;
run;

proc gchart data=foo;
hbar ip_address / type=freq freq freqlabel='Count'
 subgroup=severity
 noframe
 raxis=axis1
 autoref cref=graybb clipref
 legend=legend1
 html=myhtml
 des='' name="&name";
run;

proc format ;
 value $colorfmt
 "Security Hole"= "cxEE3B3B"
 "Security Warning" = "cxFFA812" 
 ;
run;

/* Ideally, I would write a macro, and loop through all the 
 IP addresses, calling the macro each time through */

%let ip=192.168.2.171;
ods html anchor="_&ip";
title1 font="arial/bold" height=16pt "ip_address = &ip";
proc print data=foo (where=(ip_address="&ip")) noobs;
var severity / style={background=$colorfmt.};
var port short_description;
run;

%let ip=192.168.2.172;
ods html anchor="_&ip";
title1 font="arial/bold" height=16pt "ip_address = &ip";
proc print data=foo (where=(ip_address="&ip")) noobs;
var severity / style={background=$colorfmt.};
var port short_description;
run;

%let ip=192.168.2.173;
ods html anchor="_&ip";
title1 font="arial/bold" height=16pt "ip_address = &ip";
proc print data=foo (where=(ip_address="&ip")) noobs;
var severity / style={background=$colorfmt.};
var port short_description;
run;

%let ip=192.168.2.174;
ods html anchor="_&ip";
title1 font="arial/bold" height=16pt "ip_address = &ip";
proc print data=foo (where=(ip_address="&ip")) noobs;
var severity / style={background=$colorfmt.};
var port short_description;
run;

%let ip=192.168.2.175;
ods html anchor="_&ip";
title1 font="arial/bold" height=16pt "ip_address = &ip";
proc print data=foo (where=(ip_address="&ip")) noobs;
var severity / style={background=$colorfmt.};
var port short_description;
run;

quit;
ODS HTML CLOSE;
ODS LISTING;

