/****************************************************************** This example demonstrates how the %CENTROID macro can be used how to place labels in map regions. It also shows how PROC GREMOVE can remove small choromap boundaries and only display the desired boundaries in the map. In the code below, a user-defined variable named state_county is used to make different datasets work together. /******************************************************************/ ods _all_ close; ods html file="states.html"; /* get the maps library */ libname maps "c:\Users\kelmil\maps"; proc cimport infile='c:\users\kelmil\maps\v94mapssas_all.cpt' library=maps; run; /* data for the choromap */ data us_counties; set maps.counties; if state in (2, 15, 72) then delete; /* Not AK, HI, PR */ x = -x * 45/atan(1); /* CONVERT FROM RADIANS TO DEGREES */ y = y * 45/atan(1); state_county = catx(' ',state,county); if x = . or y = . then delete; /* fips change for Oglala Lakota Co, SD to match old map data */ /* New name, Oglala Lakota (46 102), old name, Shannon (46 113) */ if state_county = "46 113" then state_county = "46 102"; run; /* data for the map response */ data zipcode; set sashelp.zipcode; where timezone in: ('Eastern', 'Central', 'Mountain', 'Pacific'); state_county = catx(' ',state,county); run; proc sort data=zipcode out=timezones nodupkey; by state_county; run; /*************************************************************/ /* This section shows how PROC GREMOVE can make a nicer map. */ /* merge timezone variable into counties dataset */ proc sort data=us_counties out=us_counties; by state_county; run; data time_counties; merge timezones us_counties; by state_county; run; /* some independent Virginia cities are now incorportated */ /* so they aren't included in the updated sashelp.zipcode */ /* remove entries with no time zone. */ data time_counties; set time_counties; where timezone ne ''; run; /* remove county boundaries and leave only time boundaries */ proc sort data=time_counties out=time_counties; by timezone; run; proc gremove data=time_counties out=rem_counties; by timezone; id state_county; run; /* data for sgmap response */ proc sort data=rem_counties out=rem_timezones nodupkey; by timezone; run; /* data for region labels */ %centroid(rem_counties, time_labels, timezone); /* This is the beginning of the Esri URL */ %let url = http://services.arcgisonline.com/arcgis/rest/services; /*** PROC SGMAP with ESRI Map, choromap and text ***/ title1 "SGMAP with CHOROMAP and Response"; title2 "CENTROID Macro Positions Time Zone Labels"; proc sgmap mapdata=rem_counties /* US Time Zone Areas */ maprespdata=rem_timezones /* US Time Zones */ plotdata=time_labels /* Text for Time Zone Labels */ noautolegend; /* Supress legend */ esrimap url= "&url/Canvas/World_Dark_Gray_Base"; choromap timezone / mapid=timezone id=timezone density=0; text x=x y=y text=timezone / textattrs=(color=cyan size=10pt); run; quit; ods _all_ close;