<?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 Re: How do I do reverse geocoding in SAS? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342202#M22650</link>
    <description>&lt;P&gt;I only have access to SAS UE, so can't test any of this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I think that the following articles are what you're looking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first one shows you how to create a zipcode map&lt;BR /&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/214-2013.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings13/214-2013.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second one shows you how to obtain the zipcodes from that map, based on only having a pair of grid coordinates, using proc ginside:&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/graphref/65389/HTML/default/viewer.htm#p0qjcc8hugcjb2n1x3bmuaar16f0.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/graphref/65389/HTML/default/viewer.htm#p0qjcc8hugcjb2n1x3bmuaar16f0.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Mar 2017 00:44:33 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-03-18T00:44:33Z</dc:date>
    <item>
      <title>How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342193#M22647</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a SAS dataset with about 200K records containing TranID, Lats and Longs. &amp;nbsp;Anyone know how can I do reverse geocoding to get the Zip Codes? &amp;nbsp;I found something about a dataset in SAS Help library but it returned only the Counties and the lats and longs need to be centoids.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Will&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 23:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342193#M22647</guid>
      <dc:creator>Lobbie</dc:creator>
      <dc:date>2017-03-17T23:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342197#M22648</link>
      <description>&lt;P&gt;Look at PROC GINSIDE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 00:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342197#M22648</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-18T00:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342199#M22649</link>
      <description>&lt;P&gt;You'll need to get hold of a shape file, then run&amp;nbsp;&lt;EM&gt;proc ginside&lt;/EM&gt; to do the &lt;A href="https://en.wikipedia.org/wiki/Point_in_polygon" target="_self"&gt;point-in-polygon&lt;/A&gt; processing. I did this successfully a few years ago at NZ Police to get &lt;A href="https://data.govt.nz/dataset/show/5544" target="_self"&gt;meshblocks&lt;/A&gt;, which could be rolled up to larger areas groups.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These shape files contain all the points bounding the area, which can in fact be multiple shapes. Read in the shape file via&amp;nbsp;&lt;EM&gt;proc mapimport&lt;/EM&gt;, then run over the generated dataset with your 200k rows with&amp;nbsp;&lt;EM&gt;ginside&lt;/EM&gt;, and the counties will automagically be included.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Often the shape files can be very wide, with all the higher grouping codes and texts, but you can drop those out with a datastep after the importing. It's vital to retain the internal order of the shape file - don't drop observations, just variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an indication, a shape file with forty-odd million rows, against a dataset with 1.6 million locations, took around 3-4 hours to run initially. Because the location dataset was being incrementally updated, the following runs on unique locations could zip through (puns always intended) in 3-4 minutes.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 00:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342199#M22649</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-03-18T00:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342202#M22650</link>
      <description>&lt;P&gt;I only have access to SAS UE, so can't test any of this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I think that the following articles are what you're looking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first one shows you how to create a zipcode map&lt;BR /&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/214-2013.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings13/214-2013.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second one shows you how to obtain the zipcodes from that map, based on only having a pair of grid coordinates, using proc ginside:&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/graphref/65389/HTML/default/viewer.htm#p0qjcc8hugcjb2n1x3bmuaar16f0.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/graphref/65389/HTML/default/viewer.htm#p0qjcc8hugcjb2n1x3bmuaar16f0.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 00:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342202#M22650</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-18T00:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342204#M22651</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WPS/SAS/R: Given Latitude and Longitude get postal_code and other geography

If you have IML interface with R you can just paste the code below

The free express edition of WPS does not limit the size of the SAS dataset
produced by R

Package also does geocoding

HAVE
====

Up to 40 obs from sd1.have total obs=1

Obs       LON        LAT

 1     -73.9738    40.7625

WANT
===

Up to 40 obs WORK.RESWPSXPO total obs=11

Obs    NAME                           VALUE

 11    POSTAL_CODE                    10022

  1    ADDRESS                        Trump, 725 5th Ave, New York, NY 10022, USA
  2    PREMISE                        Trump
  3    STREET_NUMBER                  725
  4    ROUTE                          5th Avenue
  5    NEIGHBORHOOD                   Midtown
  6    POLITICAL                      Manhattan
  7    LOCALITY                       New York
  8    ADMINISTRATIVE_AREA_LEVEL_2    New York County
  9    ADMINISTRATIVE_AREA_LEVEL_1    New York
 10    COUNTRY                        United States


WORKING CODE
============

   WPS/R

    res &amp;lt;- revgeocode(lonlat_sample, output="more");

  You can also geocode

    geo &amp;lt;- geocode("725 fifth avenue, New York NY")
    yeild see code at end

       [1] -73.97378  40.76245
       [1] 10022
       [1] Midtown

FULL SOLUTION
=============

%utl_submit_wps64('
libname sd1 "d:/sd1";
options set=R_HOME "C:/Program Files/R/R-3.3.2";
libname wrk "%sysfunc(pathname(work))";
proc r;
submit;
source("C:/Program Files/R/R-3.3.2/etc/Rprofile.site", echo=T);
library(haven);
library(ggmap);
lonlat_sample&amp;lt;-as.numeric(read_sas("d:/sd1/have.sas7bdat"));
res &amp;lt;- revgeocode(lonlat_sample, output="more");
endsubmit;
import r=res data=wrk.reswps;
run;quit;
');

proc transpose data=reswps out=reswpsxpo;
var _all_;
run;quit;


p to 40 obs from reswps total obs=1

                                                          STREET_
bs                    ADDRESS                    PREMISE  NUMBER     ROUTE

1   Trump, 725 5th Ave, New York, NY 10022, USA   Trump     725    5th Avenue


                                   ADMINISTRATIVE_  ADMINISTRATIVE_                 POSTAL
NEIGHBORHOOD  POLITICAL  LOCALITY   AREA_LEVEL_2     AREA_LEVEL_1       COUNTRY      CODE

  Midtown     Manhattan  New York  New York County     New York      United States   10022

%utl_submit_r64('
source("c:/Program Files/R/R-3.3.2/etc/Rprofile.site",echo=T);
library("ggmap");
lonlat_sample &amp;lt;- as.numeric(geocode("725 fifth avenue, New York NY"));
class(lonlat_sample);
lonlat_sample;
res &amp;lt;- revgeocode(lonlat_sample, output="more");
res$postal_code;
res$neighborhood;
');

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Mar 2017 01:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342204#M22651</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-18T01:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342205#M22652</link>
      <description>Forgot the input SAS dataset&lt;BR /&gt;&lt;BR /&gt;options validvarname=upcase;&lt;BR /&gt;libname sd1 "d:/sd1";&lt;BR /&gt;data sd1.have;&lt;BR /&gt;   lon=-73.97378;&lt;BR /&gt;   lat=40.76245;&lt;BR /&gt;run;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 18 Mar 2017 01:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342205#M22652</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-18T01:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342209#M22653</link>
      <description>&lt;P&gt;Thank you all and especially to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42345"&gt;@rogerjdeangelis&lt;/a&gt;&lt;SPAN class="login-bold"&gt;, I happened to know how to use R as well so will try the SAS &amp;amp; R solution. &amp;nbsp;thanks again.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 02:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/342209#M22653</guid>
      <dc:creator>Lobbie</dc:creator>
      <dc:date>2017-03-18T02:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/348468#M22995</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42345"&gt;@rogerjdeangelis&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the following error when trying out your solution in WPS. &amp;nbsp;Any clues?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8230i0D44F065E18EE87B/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="2017-04-09_11-25-49.png" title="2017-04-09_11-25-49.png" /&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Will&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 01:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/348468#M22995</guid>
      <dc:creator>Lobbie</dc:creator>
      <dc:date>2017-04-09T01:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do reverse geocoding in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/348511#M22996</link>
      <description>&lt;P&gt;Check out&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2011/05/13/calling-r-from-sasiml-software.html" target="_blank"&gt;http://blogs.sas.com/content/iml/2011/05/13/calling-r-from-sasiml-software.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;use the excellect SAS help facilities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 12:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-do-reverse-geocoding-in-SAS/m-p/348511#M22996</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-04-09T12:46:29Z</dc:date>
    </item>
  </channel>
</rss>

