Click here to see the SAS code.
This is similar to the example in "democd1", but this one has some
extras added, such as the contour plot.
================================================================
This example is probably one of the most in-"depth", multi-part,
examples I've done (pun intended! ;) ...
All of these maps and charts were programmatically derived
from the info in the following 2 spreadsheets (and by putting
your/similar data in these spreadsheets and re-running the
sas job, new maps and charts would be produced using your
data)...
Click here to see the artifacts spreadsheet.
Click here to see the sites spreadsheet.
All of the sites have data & pictures, but the most detailed data
is in the Allendale county, South Carolina sites (since that's the site
that I spent the most time at, and am most familiar with :)
---
There are actually 2 versions of this sample, in 2 directories:
arch2/ = the new version that uses the v9.2 'longnames' sas/graph option,
along with several other enhancements over the 'old' arch version.
arch/ = the 'old' version (have to use a lot of tricks to get the
long filenames, etc).
This document describes the 'arch2' version...
I have been a volunteer on several archaeological digs, and at
all of these digs I noted that they kept very meticulous records
on the exact x/y & depth coordinates and holes that each artifact
came from (this way, they could lookup the info later, and mentally
reconstruct the digsite later).
Being a computer graphics & mapping guy, I thought it would be
neat to show how such data might be used to graphically/visually
reconstruct the dig-sites! :-)
First, I created a bunch of "plausibly-real" data, and stored it
in excel spreadsheets. These spreadsheets are read directly into
sas using "SAS/ACCESS to PC File Formats". There is one spreadsheet
listing information about the dig sites, and one spreadsheet with
information about all the artifacts (one line per each artifact).
Creating plausibly-real fake data is time-consuming work, and I have
therefore only created data for a few dozen artifacts -- in a real
digsite there would be data for several thousand (or hundreds of
thousand) artifacts.
When I read in the artifact data, I categorize each artifact, and
assign variables that I'll later use for the markers in the plots.
The variables I assign here will control the color, shape, and
size of the markers in the 3d 'cube' plots.
I then create my top-level US map (US_MAP) - each state for which I
have archaeological dig data is colored red. I use sas/graph 'proc
gmap's html= option to code in the html drilldown & charttip/flyover-text.
You can click on the red states to drilldown.
---
I then define a bunch of macros - scroll to the bottom of the program
to see where I start running the macros. At the bottom of the program,
I generate a data set containing a list of all the states that have
artifacts, and I use a "data _null_" to loop through all these states
and call the %state_macro() to draw the state map, showing county
division lines, and with red dots where the dig sites are located.
Note that in the state map, I use gmap's html= to provide the
html title= charttips/flyover-text and href= drilldown for the
counties (I get the county names from the maps.cntyname data set,
and I use annotated text to place the county names on the map.)
I use 'proc gproject' to re-project the raw map long/lat boundaries,
so that the maps will look "straight" when they're drawn.
When I draw the states, I use 'by state' (even though I'm only
mapping one state at a time), and I suppress the default by-title
(using the 'options nobyline'), and I utilize the by-value in my
custom title as follows...
title1 "Archaeological Digs in #byval(state)";
At the bottom of this macro, I go through a "data _null_" loop
to call the %county_macro() for each of the counties.
---
For the county maps, first I select that county from the
maps.county sas/graph map data set, and also the location info
for the sites in this county from my 'sites' data (I will use
the sites info to annotate the red site dots at the long/lat
of the sites).
I merge in the county name (from maps.cntyname) to use as the
'by' variable, so I can print it in the title. I add some variables
to the county_anno data set so that it has the annotate info it
needs (xsys, ysys, hsys, etc), and I create an annotate red 'pie'
at each dig site. I also do a black circle (empty pie) around each
red pie, so they have an outline. I add an 'html' variable in the
annotate data set, so I have the html title= charttip/flyover-text
(with the site number & name) and href= drilldown to show a map of
the holes at that site. I also set up an htmlvar for the county
land area, but I decided not to use that (to avoid confusion).
I then combine the map & annotate data, and project them together,
and then separate them again. Note that I use the 'dupok' annotate
option, since my red dot & black circle are at exactly the same
location, and I want both obsns to be kept (it took a while to
figure out to use that option, therefore I thought it was worth
mentioning ;)
I then do some ODS statements, and use sas/graph's 'proc gmap'
to draw the map.
At the bottom of this macro, I go through a "data _null_" loop
to call the %site_macro() for each of the sites in this county.
---
The site_macro shows the layout of all the excavated holes (generally
1x1-meter holes) excavated at that site. The holes are shown on a map
in the correct layout, proportion, and size in relation to each other,
and each hole has an annotated label (I place the label at the average
x/y location, which is the 'center' of the hole).
When I draw the map of the rectangular 'holes', I use gmap's html= option
to encode html title= charttip/flyover-text, and href= drilldown. When
you click on a hole, it allows you to drilldown and see all the artifacts
in that hole.
At the bottom of this macro, I go through a "data _null_" loop
to call the %hole_macro() for each of the holes at this site.
---
The hole_macro selects all the artifacts for the given hole, and
creates a couple of 3d visualizations of that data.
First, 'proc g3d' is used to show a true 3d view of the artifacts.
I use device=activex so that you can interactively rotate the cube
(using Alt+left-mouse-button, or using right-mouse-button -> graph
toolbar). Also the activex version shows you a charttip with the
x, y, and depth values (proc g3d does not support custom html
title= charttips, therefore if I had used dev=gif I would have had
no way to do charttips at all in this chart ... another reason I
used dev=activex for this particular chart!)
Scroll down, and you'll see another 3d visual representation of the
data in the hole. This time I do simple 'proc gplot's, looking
at the data from 3 different directions (overhead, from the south,
and from the east). I then take these 3 gplots and draw them onto
a custom greplay template (this template is composed of 3 areas,
and the areas are arranged such that they look like a perspective
view of a 3d cube). So, what you're looking at is 3 walls of a
cube, with all the artifacts "projected" out to that wall of the
cube (so you're seeing all of the artifacts 3 times - once on
each face of the cube). It takes a little while to get used to
looking at this one, but it helps you see trends in the data.
Also, since it uses 'proc gplot' I am able to do custom html
title= charttips/flyover-text, and also href= drilldowns.
Therefore you can click on the markers in this one, and
drilldown to a picture of that artifact! (this was not possible
in the g3d cube, since it doesn't support the html= option!)
Note that since I don't have pictures of hundreds of artifacts,
I have just set up this example to drilldown to a generic image
of that category of artifact (but it would be easily set up to
show a picture of the actual artifact, if individual pictures
were available, of course!)
And, gplot lets me control the axes, so I can force them to
go from 0->100 (or whatever I want). By comparison, g3d
always auto-selects it's own x & y axes, and doesn't let me
control this (with sparse data, it is unlikely that it will
auto-select 0->100 for the x & y axes in the g3d).
To save space in this 'cube' view, I don't show the color/shape
legend on the same page (it would take up too much space, and
force the cube to be smaller). Instead, I put the legend on
the next page. Since I'm using annotate to draw the markers,
there is no 'automatic' legend -- rather, I have to also draw
the legend using annotate. I do this programmatically, based
on the data, so it's not too cumbersome :)
After the 3d cubes and legend, I show a table listing all the
artifacts, using 'proc report'. I could have used 'proc print',
but the 'proc report' allows me to add drilldown links to the
text. Ideally, I would have a unique picture for each artifact,
and I would then show the artifact number, and have a link to
a picture of that individual artifact. But since I only have
a generic picture of each 'category' of artifact, I am just
putting a link on the category, so you can click on it and
see the generic picture for that category.
Back to Samples Index