Click here to see the SAS code.
Click here to see the example.

Click here to see the example (2016).

---------------------------------------------------------------

See my blog for more information!


The main 'trick' in this example is reading the pirate attack locations
from a web page.  All of the locations were basically in 1 very long line
in the html of a web page.  Rick Langston helped me with the tricky SAS
code to read & parse that long line.

Once I have the lat/long data, I annotate it onto a SAS/Graph gmap,
and then also create a cumulative gplot of the same data.

And last, but not least, I create a table of the data, with 
"traffic light" coloring to correspond to the colors of the markers
used in the map & scatter plot.

-----

Here are some details (from Rick Langston) on the trick used to read 
the data from the web page:

The idea is to read the entire HTML file using the URL access method, 
but with RECFM=F LRECL=1 and every byte is counted and saved to a local 
file, with the byte count put in the macro variable &filesize. 
Then you can do this:

data _null_; infile local recfm=f lrecl=&filesize. column=c missover; 

and the file will be treated as one long record. Use the input @'....' 
mechanism to get to a particular set of characters. Since MISSOVER is set, 
if c>&filesize. you've gone past the end and you stop. 
What I do is look for {"0":" and then I know the value of c is the column for the first digit, 
then look for " and then I know the length of the value, 
then I use input @start x $varying100. l to get the actual characters, 
then inputn can be used to read them input as a number. 

Back to Samples Index