%let name=wheat; filename odsout '.'; goptions reset=global; /* Using data from ... http://www.nass.usda.gov/ks/crops/2003/cropjun.pdf */ data a; input st $ 1-2 value; state=stfips(st); cards; KS 33 OK 28 WA 59 TX 29 CO 22 NE 32 OH 62 MT 28 ID 79 SD 29 ; run; proc sql; /* Sort, so small dots will print on top */ create table a as select unique state, value from a order by value descending; /* Find the x/y center of each state */ create table a as select a.*, uscenter.* from a left join maps.uscenter on a.state=uscenter.state; quit; run; data a; set a; length html $500; html='title='|| quote( 'State: '||trim(left(fipnamel(state)))||'0D'x|| 'Value: '||put(value,comma10.0)||' ' ); if ocean ne 'Y' then output; run; %let dot_space=.008; /* this is in the map x/y coordinate number system */ %let dot_size=.4; /* this is in % of the graphics area */ /* Create dataset containing grids-of-dots for each state. Start the grid in the center of the state, and build it up going from the top/left corner, then going across the row, and then going to the left-side of the next row, and so on. (re-center the grid-of-dots later. */ data dots; set a; length function color $ 8; xsys='2'; ysys='2'; hsys='3'; when='A'; function='PIE'; style='SOLID'; if value le 30 then color='magenta'; else if value le 50 then color='green'; else if value le 70 then color='blue'; else if value gt 70 then color='red'; rotate=360; size=&dot_size; /* Round up, to get grid of dots to tend to be wider than tall. Adjust this to suit your preferences, and the general orientation and proportions of your map areas - US map tends to have map areas that are wider than tall, so I'm doing it this way. */ gridsize=int(sqrt(value)+.5); if gridsize eq 1 then gridsize=2; orig_x=x; orig_y=y; x_offset=0; y_offset=0; do loop = 1 to value; output; x_offset=x_offset+1; if (x_offset+1) > gridsize then do; x_offset=0; y_offset=y_offset+1; end; x=orig_x+(x_offset*&dot_space); y=orig_y-(y_offset*&dot_space); end; run; /* Now, re-center the grids-of-dots */ data dots; set dots; if (gridsize gt 2) then x=x-(gridsize/2 * &dot_space); if (gridsize gt 2) then y=y+(gridsize/2 * &dot_space); run; GOPTIONS DEVICE=png; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="2002 Wheat Yield Per Acre") style=minimal ; goptions border; goptions iback='wheatfield.jpg' imagestyle=fit; goptions gunit=pct ftitle="arial" ftext="arial" htitle=7 htext=4.2; title1 'Winter Wheat Production'; title2 'Selected States, Bushels per Acre, year 2002'; pattern1 v=e c=brown r=1000; proc gmap data=a map=maps.us anno=dots all; where fipstate(state) not in ('AK' 'HI' 'PR'); id state; choro state / nolegend discrete coutline=brown woutline=3 html=html des="" name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;