<?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: PROC HTTP to allow parameters in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963559#M83954</link>
    <description>&lt;P&gt;The URL to be used ends in addressbatch,&amp;nbsp; see&amp;nbsp;&lt;A href="https://geocoding.geo.census.gov/geocoder/Geocoding_Services_API.html#_Toc172117435" target="_blank"&gt;https://geocoding.geo.census.gov/geocoder/Geocoding_Services_API.html#_Toc172117435&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each --form option of the curl command must be specified as a comma separated list using the&amp;nbsp;IN=MULTI FORM( ..., ..., ...) option of Proc HTTP.&lt;BR /&gt;&lt;BR /&gt;Here is a working example using the same file as in the previous example as input:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename resp temp;
proc http
  method="POST"
  url="https://geocoding.geo.census.gov/geocoder/geographies/addressbatch"
  in=multi form (
    "addressFile" = addr filename="local.csv" header="Content-Type: application/octet-stream" 
    , "benchmark" = "4" nofilename header="Content-Type: text/plain" 
    , "vintage" = "4" nofilename header="Content-Type: text/plain" 
  )
  out=resp
  verbose
;
  debug level=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have used the curl --trace tracefile.txt ... command to see how the information was passed and adapted the options for the&amp;nbsp;IN=MULTI FORM( ..., ..., ...) option accordingly.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Apr 2025 07:27:43 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2025-04-07T07:27:43Z</dc:date>
    <item>
      <title>PROC HTTP to allow parameters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963233#M83948</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to get geo info like census tract given a list of addresses through the site &lt;A href="https://geocoding.geo.census.gov/geocoder/geographies/address?street=" target="_blank"&gt;Census Geocoder&lt;/A&gt;, but cannot make PROC HTTP work so far.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the code I have for the address of white house, 1600 Pennsylvania Ave NW,Washington, DC, 20500&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename response temp;&lt;BR /&gt;proc http&lt;BR /&gt;url="&lt;A href="https://geocoding.geo.census.gov/geocoder/geographies/address?street=1600+Pennsylvania+Ave+NW&amp;amp;city=Washington&amp;amp;state=DC&amp;amp;zip=20500&amp;amp;benchmark=Public_AR_Current&amp;amp;vintage=Current_Current&amp;amp;format=json" target="_blank"&gt;https://geocoding.geo.census.gov/geocoder/geographies/address?street=1600+Pennsylvania+Ave+NW&amp;amp;city=Washington&amp;amp;state=DC&amp;amp;zip=20500&amp;amp;benchmark=Public_AR_Current&amp;amp;vintage=Current_Current&amp;amp;format=json&lt;/A&gt;"&lt;BR /&gt;method="GET"&lt;BR /&gt;out=response;&lt;BR /&gt;run;&lt;BR /&gt;libname resp json fileref=response;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got the warning messages as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference STATE not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference STATE not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference BENCHMARK not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference VINTAGE not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference FORMAT not resolved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, I have about 100 addresses that I need to loop through. How can I set loop through using the address data set as below:&lt;/P&gt;
&lt;P&gt;data address;&lt;BR /&gt;infile datalines dlm=',' dsd;&lt;BR /&gt;input id $ street $ city $ state $ zip $;&lt;BR /&gt;datalines;&lt;BR /&gt;1,1600 Pennsylvania Ave NW,Washington,DC,20500&lt;BR /&gt;2,1234 Main street, City, DC, 12345&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;Any suggestions are greatly appreciated!&lt;/P&gt;
&lt;P&gt;L.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 18:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963233#M83948</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2025-04-02T18:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to allow parameters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963234#M83949</link>
      <description>&lt;PRE&gt;url='https://geocoding.geo.census.gov/geocoder/geographies/address?street=1600+Pennsylvania+Ave+NW&amp;amp;city=W...'&lt;/PRE&gt;
&lt;P&gt;Try it with single quotes.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 18:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963234#M83949</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2025-04-02T18:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to allow parameters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963283#M83950</link>
      <description>&lt;P&gt;I believe it works with single quote, but I'm not sure how to interpret the log. The log was generated as in the screenshot below but no dataset or anything else. I thought it would write out geo info in certain form -- sorry that I'm accessing URL from SAS for the first time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lichee_0-1743648614856.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105876iB6CD3352443CCAD1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lichee_0-1743648614856.png" alt="lichee_0-1743648614856.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;29 filename response temp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;30 proc http&lt;BR /&gt;31 url='&lt;A href="https://geocoding.geo.census.gov/geocoder/geographies/address?street=1600+Pennsylvania+Ave+NW&amp;amp;city=Washington&amp;amp;sta" target="_blank"&gt;https://geocoding.geo.census.gov/geocoder/geographies/address?street=1600+Pennsylvania+Ave+NW&amp;amp;city=Washington&amp;amp;sta&lt;/A&gt;&lt;BR /&gt;31 ! te=DC&amp;amp;zip=20500&amp;amp;benchmark=Public_AR_Current&amp;amp;vintage=Current_Current&amp;amp;format=json'&lt;BR /&gt;32 method="GET"&lt;BR /&gt;33 out=response;&lt;BR /&gt;34 run;&lt;/P&gt;
&lt;P&gt;NOTE: 200 OK&lt;BR /&gt;NOTE: PROCEDURE HTTP used (Total process time):&lt;BR /&gt;real time 0.30 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;35 libname resp json fileref=response;&lt;BR /&gt;NOTE: JSON data is only read once. To read the JSON again, reassign the JSON LIBNAME.&lt;BR /&gt;NOTE: Libref RESP was successfully assigned as follows: &lt;BR /&gt;Engine: JSON &lt;BR /&gt;Physical Name: /saswork/SAS_workF4AE001C33F4_pd-sas-grd7.awscloud.cms.local/#LN00134&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2025 02:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963283#M83950</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2025-04-03T02:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to allow parameters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963287#M83951</link>
      <description>&lt;P&gt;When it comes to the WARN,INGs, SAS tries to interpret all words that is prefixed with the &amp;amp;-sign as a macro variable, unless they are within single qoutes, or dealt with using a macro masking function.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2025 05:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963287#M83951</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-04-03T05:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to allow parameters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963298#M83952</link>
      <description>&lt;P&gt;I would use the QUERY=() option, this allows to specify the name=value pairs in an easy way.&lt;BR /&gt;&lt;BR /&gt;See example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename resp temp;
proc http
url="https://geocoding.geo.census.gov/geocoder/geographies/address"
method="GET"
query=(
"street" = "1600 Pennsylvania Ave"
"city" = "Washington"
"state" = "DC"
"format" = "json"
"benchmark" = "4"
"vintage" = "4"
"returntype" = "geographies"
"searchtype" = "address"

)

out=resp
verbose
;
run;
%put %sysfunc(jsonpp(resp, log));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As for the second question, pass a file with address lines, have a look at this example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename addr temp;
data _null_;
  infile datalines;
  input;
  file addr;
  ll = length(_infile_);
  put _infile_ $varying256. ll;
datalines;
1,1600 Pennsylvania Ave NW,Washington,DC,20500
2,1234 Main street,City,DC,12345
;

filename resp temp;
proc http
  method="POST"
  url=https://geocoding.geo.census.gov/geocoder/locations/addressbatch 
  in=multi form (
    "addressFile" = addr filename="local.csv" header="Content-Type: application/octet-stream" 
    , "benchmark" = "2020" nofilename header="Content-Type: text/plain" 
  )
  out=resp
  verbose
;
  debug level=0;
run;


data _null_;
  infile resp;
  input;
  putlog _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Apr 2025 15:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963298#M83952</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2025-04-03T15:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to allow parameters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963355#M83953</link>
      <description>&lt;P&gt;Thanks a lot!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first part works well. For the second part for a list of addresses, based on the log requesting entering "vintage" info, I modified the code your provided slightly as below,&amp;nbsp; but&amp;nbsp;still get "400 Bad Request".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc http&lt;BR /&gt;method="POST"&lt;BR /&gt;url="&lt;A href="https://geocoding.geo.census.gov/geocoder/geographies/address" target="_blank"&gt;https://geocoding.geo.census.gov/geocoder/geographies/address&lt;/A&gt;" &lt;BR /&gt;in=multi form (&lt;BR /&gt;"addressFile" = addr filename="local.csv" header="Content-Type: application/octet-stream" &lt;BR /&gt;, "benchmark" = "4", "vintage" = "4" nofilename header="Content-Type: text/plain" &lt;BR /&gt;)&lt;BR /&gt;out=resp&lt;BR /&gt;verbose&lt;BR /&gt;;&lt;BR /&gt;debug level=0;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lichee_0-1743705617979.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105883i81235E6E4E45FEFF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lichee_0-1743705617979.png" alt="lichee_0-1743705617979.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2025 18:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963355#M83953</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2025-04-03T18:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP to allow parameters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963559#M83954</link>
      <description>&lt;P&gt;The URL to be used ends in addressbatch,&amp;nbsp; see&amp;nbsp;&lt;A href="https://geocoding.geo.census.gov/geocoder/Geocoding_Services_API.html#_Toc172117435" target="_blank"&gt;https://geocoding.geo.census.gov/geocoder/Geocoding_Services_API.html#_Toc172117435&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each --form option of the curl command must be specified as a comma separated list using the&amp;nbsp;IN=MULTI FORM( ..., ..., ...) option of Proc HTTP.&lt;BR /&gt;&lt;BR /&gt;Here is a working example using the same file as in the previous example as input:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename resp temp;
proc http
  method="POST"
  url="https://geocoding.geo.census.gov/geocoder/geographies/addressbatch"
  in=multi form (
    "addressFile" = addr filename="local.csv" header="Content-Type: application/octet-stream" 
    , "benchmark" = "4" nofilename header="Content-Type: text/plain" 
    , "vintage" = "4" nofilename header="Content-Type: text/plain" 
  )
  out=resp
  verbose
;
  debug level=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have used the curl --trace tracefile.txt ... command to see how the information was passed and adapted the options for the&amp;nbsp;IN=MULTI FORM( ..., ..., ...) option accordingly.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2025 07:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-to-allow-parameters/m-p/963559#M83954</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2025-04-07T07:27:43Z</dc:date>
    </item>
  </channel>
</rss>

