Tips and Tricks II: Getting the most from your SAS/Graph Maps
Tips and Tricks II: Getting the most from your SAS/Graph Maps
Tips and Tricks II: Getting the most from your SAS/Graph Maps
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
more accurate to geocode <strong>the</strong> street addresses <strong>and</strong> plot those, but you need a package<br />
with geocoding capability like <strong>SAS</strong>/GIS.<br />
%macro dot_density(indata,outdata,spread,dotsize,color,idvar);<br />
/*----------------------------------------------------------------*/<br />
/* Create an annotate data set with a r<strong>and</strong>omized 'dot' a each */<br />
/* location. This simulates a dot-density map so that all dots */<br />
/* <strong>the</strong> same location do not appear directly on top of each o<strong>the</strong>r. */<br />
/* The user must adjust spread <strong>and</strong> dotsize for <strong>the</strong>ir map needs. */<br />
/* */<br />
/* Arguments: */<br />
/* indata= input data set; outdata= output data set; */<br />
/* spread= offset <strong>from</strong> center point in any direction. */<br />
/* dotsize= size of dot for each value */<br />
/* color= color of dot; idvar= variable to use in tooltip */<br />
/* Notes: Dotsize <strong>and</strong> spread must change depending on <strong>the</strong> scale */<br />
/* of <strong>the</strong> Map, whe<strong>the</strong>r you are using degrees or radians */<br />
/* <strong>and</strong> <strong>the</strong> number of items you are showing. The dot size */<br />
/* may also vary between different types of output */<br />
/* (eg, Gif, Java, actx) */<br />
/* Warning: Dot-density maps (or dot maps) are not 'accurate' */<br />
/* because of <strong>the</strong> r<strong>and</strong>om nature of <strong>the</strong> map <strong>and</strong> only show patterns.*/<br />
/* Accuracy is better when you are showing a smaller area <strong>and</strong> */<br />
/* fewer items. */<br />
/*----------------------------------------------------------------*/<br />
data &outdata;<br />
set &indata;<br />
length function style color $ 8 position $ 1 text $ 20 ;<br />
retain xsys ysys '2' hsys '3' when 'a' text '' ;<br />
retain rotate 360 style 'solid' function 'pie' position '5';<br />
anno_flag=1; /*so we can separate <strong>the</strong> datasets later*/<br />
color=&color;<br />
size=&dotsize;<br />
spread=&spread;<br />
/* create r<strong>and</strong>omness around centroid so you can see */<br />
/* more than one dot */<br />
x=x- spread + (spread*2)*rannor(0);<br />
y=y- spread + (spread*2)*rannor(0);<br />
output;<br />
run;<br />
%mend;<br />
4) Reduce <strong>the</strong> map <strong>and</strong> only keep <strong>the</strong> counties you are interested in.<br />
5) Combine <strong>the</strong> map data <strong>and</strong> annotate map <strong>and</strong> GPROJECT <strong>the</strong>m toge<strong>the</strong>r. Then split<br />
<strong>the</strong>m apart.<br />
6) Display <strong>the</strong> map.