<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create Maps from US Zipcode Lat/Longs in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194454#M7204</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there, I am wondering if it is possible to use a table of US zipcode lat/longs to create a map in SAS using PROC GMAP.&amp;nbsp; I realize there are US state/county maps, as well as a specific zip code reference file, but I have some custom regions that I would like to display and the only way I can access the GIS information is via zip code lat/longs (This would be similar to rolling up zip codes into US Senate districts). I currently complete this task using another GIS system and then using proc mapimport, but keeping it all in SAS would be much more efficient and allow for regular updates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using the code below, though I think I have a problem with my X/Y conversion or the sorting of the table.&amp;nbsp; I've also attached a sample data file for just Utah zip codes that demonstrates the data structure (this would be the zipcode table in the first data statement).&amp;nbsp; Any assistance is greatly appreciated.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data addXY;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set zipcode;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x=atan(1)/45 * longitude;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=atan(1)/45 * latitude;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc greduce data=addXY out=map_reduced;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id region;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_reduced&lt;/SPAN&gt;; by region; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc gproject data=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_reduced&lt;/SPAN&gt; out=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_proj&lt;/SPAN&gt; eastlong degrees;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id Region;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods listing close;&lt;/P&gt;&lt;P&gt;goptions reset=all;&lt;/P&gt;&lt;P&gt;ods html path = '.' (url=none) file='TestZip.html' style=sasweb;&lt;/P&gt;&lt;P&gt;ods html newfile=output;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;goptions hsize=15in vsize=10in;&lt;/P&gt;&lt;P&gt;goptions xpixels=250 ypixels=250;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc gmap data=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_proj&lt;/SPAN&gt; map=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_proj &lt;/SPAN&gt;all density=low;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id region;&lt;/P&gt;&lt;P&gt;&amp;nbsp; choro region / nolegend;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ODS HTML CLOSE;&lt;/P&gt;&lt;P&gt;ODS LISTING;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Mar 2015 19:00:11 GMT</pubDate>
    <dc:creator>P5C768</dc:creator>
    <dc:date>2015-03-04T19:00:11Z</dc:date>
    <item>
      <title>Create Maps from US Zipcode Lat/Longs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194454#M7204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there, I am wondering if it is possible to use a table of US zipcode lat/longs to create a map in SAS using PROC GMAP.&amp;nbsp; I realize there are US state/county maps, as well as a specific zip code reference file, but I have some custom regions that I would like to display and the only way I can access the GIS information is via zip code lat/longs (This would be similar to rolling up zip codes into US Senate districts). I currently complete this task using another GIS system and then using proc mapimport, but keeping it all in SAS would be much more efficient and allow for regular updates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using the code below, though I think I have a problem with my X/Y conversion or the sorting of the table.&amp;nbsp; I've also attached a sample data file for just Utah zip codes that demonstrates the data structure (this would be the zipcode table in the first data statement).&amp;nbsp; Any assistance is greatly appreciated.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data addXY;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set zipcode;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x=atan(1)/45 * longitude;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=atan(1)/45 * latitude;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc greduce data=addXY out=map_reduced;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id region;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_reduced&lt;/SPAN&gt;; by region; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc gproject data=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_reduced&lt;/SPAN&gt; out=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_proj&lt;/SPAN&gt; eastlong degrees;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id Region;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods listing close;&lt;/P&gt;&lt;P&gt;goptions reset=all;&lt;/P&gt;&lt;P&gt;ods html path = '.' (url=none) file='TestZip.html' style=sasweb;&lt;/P&gt;&lt;P&gt;ods html newfile=output;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;goptions hsize=15in vsize=10in;&lt;/P&gt;&lt;P&gt;goptions xpixels=250 ypixels=250;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc gmap data=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_proj&lt;/SPAN&gt; map=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;map_proj &lt;/SPAN&gt;all density=low;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id region;&lt;/P&gt;&lt;P&gt;&amp;nbsp; choro region / nolegend;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ODS HTML CLOSE;&lt;/P&gt;&lt;P&gt;ODS LISTING;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 19:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194454#M7204</guid>
      <dc:creator>P5C768</dc:creator>
      <dc:date>2015-03-04T19:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create Maps from US Zipcode Lat/Longs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194455#M7205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand your goal, these are the steps I think you need to do:&lt;/P&gt;&lt;OL style="list-style-type: decimal;"&gt;&lt;LI&gt;import zipcode shapefiles into SAS using PROC MAPIMPORT&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;After import, you will convert&amp;nbsp; these lat / long coordinates to x/y using atan using code.&amp;nbsp; IMPORTANT – for GMAP, the longitude coordinates for the western hemisphere need to be positive.&amp;nbsp; So you may need to use abs() to convert long from negative to positive.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. merge zipcode shapefile with dataset that identifies zipcodes with regions&lt;/P&gt;&lt;P&gt;If there are zipcodes that are not associated with special regions, you will still need to assign them unique region numbers.&amp;nbsp; Otherwise the unassigned zipcodes will be reduced into one mega-region in the PROC GREDUCE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3. do PROC GREDUCE based on region&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4. do PROG GPROJECT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5. create choropleth map with PROC GMAP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 23:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194455#M7205</guid>
      <dc:creator>sunnyrj</dc:creator>
      <dc:date>2015-03-04T23:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create Maps from US Zipcode Lat/Longs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194456#M7206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ZIP Codes are points and you are trying to draw polygons with them.&lt;/P&gt;&lt;P&gt;They likely overlap and such.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe a better way would be to draw the points as colors. I am using annotate.&amp;nbsp;&amp;nbsp; In my example, I only use 4 colors and black for the rest but you can add as many colors as you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="9459" alt="gmap.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/9459_gmap.png" /&gt;&lt;/P&gt;&lt;P&gt;Here is the program:&lt;BR /&gt;%make_dots(annodata, zipcode, 'red'); &lt;BR /&gt;data annodata; set annodata; x=long; y=lat;&amp;nbsp; &lt;BR /&gt;if region=1 then color='red'; &lt;BR /&gt;else if region=2 the color='yellow'; &lt;BR /&gt;else if region=3 the color='blue'; &lt;BR /&gt;else if region=4 the color='green'; &lt;BR /&gt;/*etc*/ &lt;BR /&gt;else color='black'; &lt;BR /&gt;run; &lt;BR /&gt;data utah; set mapsgfk.us_states (where=(statecode="UT")); x=long; y=lat; run; &lt;BR /&gt;proc gmap data=utah map=utah anno=annodata; id statecode ; choro statecode; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro is here:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro make_dots(annodata, inputdata, color, size, tipvar); &lt;BR /&gt;data &amp;amp;annodata; &lt;BR /&gt;&amp;nbsp; length function color $ 8 style $20 position $ 1 text $ 60 html $1024; &lt;BR /&gt;&amp;nbsp; retain xsys ysys '2' hsys '3' when 'a' size .7; &lt;BR /&gt;&amp;nbsp; set &amp;amp;inputdata; &lt;BR /&gt;&amp;nbsp; /*optional arguments*/ &lt;BR /&gt;&amp;nbsp; %if (&amp;amp;size ^= ) %then %do; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; size=&amp;amp;size; &lt;BR /&gt; %end; &lt;BR /&gt;&amp;nbsp; /* All annotate points are 360-degree pies.&amp;nbsp; */ &lt;BR /&gt;&amp;nbsp; function='pie'; &lt;BR /&gt;&amp;nbsp; rotate=360; &lt;BR /&gt;&amp;nbsp; style='psolid'; &lt;BR /&gt;&amp;nbsp; color=&amp;amp;color; &lt;BR /&gt;&amp;nbsp; /* optional tool tips */ &lt;BR /&gt;&amp;nbsp; %if (&amp;amp;tipvar ^= ) %then %do; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; html= 'title=' || quote("&amp;amp;tipvar" ||'=' || trim(left(&amp;amp;tipvar)) ); &lt;BR /&gt;&amp;nbsp; %end; &lt;BR /&gt; output; &lt;BR /&gt; /* Draw an outline around each 'dot' */ &lt;BR /&gt; color="gray55"; style='pempty'; &lt;BR /&gt; output; &lt;BR /&gt;run; &lt;BR /&gt;%mend;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 15:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194456#M7206</guid>
      <dc:creator>Darrell_sas</dc:creator>
      <dc:date>2015-03-05T15:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create Maps from US Zipcode Lat/Longs</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194457#M7207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have acceptable levels from you current GIS I would try creating a map dataset with the polygons for&amp;nbsp; each zip code to import into SAS. One recurring issue, especially with western states is that many existing Zip code map sets have large gaps of geography not associated with any zip. Or at least that was my experience starting with available Census boundary sets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 16:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-Maps-from-US-Zipcode-Lat-Longs/m-p/194457#M7207</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-03-05T16:37:57Z</dc:date>
    </item>
  </channel>
</rss>

