/*This code produces a "day" view of the population of cities in Kansas. Need table(s) containing 2000 Population, annotated x&y coordinates for each city (I used the built in SAS data set for cities in Kansas), and city label (name or fipscode). Also need a table to draw outline of counties (Again, I used the built in SAS data set for this). The radius of the city is given by .5 + (city pop. in 2000 census/range of city pops in state) * 5. --- OUTPUT IS GIF570 ---- */ /*Written by Xanthippe Stevens (4/10/2001), Policy Research Institute, The University of Kansas, 1541 Lilac Lane, Suite 607 Lawrence, KS 66044-3177, email: xan@ku.edu */ libname dataloc 'd:\data\citydata\'; filename giffile 'd:\data\citydata\dayview.gif'; data citydata; /*file datarch contains all of our city level data, selecting only 2000 pop for this application*/ set dataloc.datarch; where varname="TOTPOP" and year=2000; length cityfips 5; cityfips=place; drop place; run; data blanks; /*this routine merely creates a fake dataset in order to outline the county boundaries */ retain cfill 1; do county=1 to 209 by 2; output; end; run; proc sql; /*Need the maximum and minimum populations of the cities in order to create the range needed to calculate the radius */ select max(value) , min(value) into :maxval, :minval from citydata; /*merge citydata with annotated coordinates for each city*/ create table city as select d.x, d.y, d.city, c.* from citydata as c, dataloc.cityanno as d where c.cityfips=d.place order by cityfips; quit; data anno; /*this routine uses the annotated city data set to create pie shapes where the radius is based on the 2000 population */ length function style color $8; set city (keep=x y city value); xsys='2'; /*3=percentage of graphics output area, 4=cell in graphics output area*/ ysys='2'; hsys="1"; style='pempty'; position='5'; color='blue'; x=x; y=y; function='pie'; angle = 0; rotate= 360; valrange=&maxval-&minval; /* note: the variable "value" contains the 2000 Population*/ size = .5 + (value/valrange)*5; line=0; when='A'; output; run; /* White backround, black text, and a light grey border for counties*/ goptions reset=global gunit=pct border cback=white colors=(white) device=gif570 gsfname=giffile ctext=black ftext=swiss htitle=6 htext=3; title1 'Kansas Cities, Population 2000'; footnote1 j=r 'Source: U.S. Census Bureau '; proc gmap map=dataloc.countymap data=blanks; id county; choro cfill/discrete nolegend coutline=cxCCCCCC annotate=anno; run; quit;