Monday, December 30, 2013

SAS and Bing Maps API

Here is a method for using SAS and Bing Maps:

  1. Signed up for a key on Bing Maps API. Create a basic key and copy it somewhere. I will demonstrate it in the SAS code as [BINGKEY] since I cannot share mine publicly:

  2. Use the following code:
  3. %let z1=47.64054;
    %let z2=-122.12934;
    %let BINGKEY=%NRSTR(&key=[BINGKEY]);

    filename x url ",&z2.?o=xml&BINGKEY";
    filename z "c:\temp\BingMap.xml";

    data _null_;
    infile x ;
    file z ;
    put _INFILE_;

  4. Parse the xml that is produced as needed. You can also output it as JSON if you change the word xml in the URL to json.

For setting SAS Options in code, make sure you have the following dlls: Interop.SAS SASObjectManager SASWorkspaceManager For...