<?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: ERROR: ERROR: Bad request. Use the debug option for more info. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918333#M361739</link>
    <description>Thank you so much. I figured the issue had to do with address formatting. much appreciate your kind support</description>
    <pubDate>Wed, 28 Feb 2024 22:11:40 GMT</pubDate>
    <dc:creator>Ihsan-Mahdi</dc:creator>
    <dc:date>2024-02-28T22:11:40Z</dc:date>
    <item>
      <title>ERROR: ERROR: Bad request. Use the debug option for more info.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918303#M361726</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I used the macro below to calculate shortest driving distances between a set of addresses. I got the error "ERROR: Bad request. Use the debug option for more info."&lt;/P&gt;
&lt;P&gt;I used this code to check "filename gmaps url&lt;BR /&gt;'&lt;A href="http://support.sas.com/techsup/service_intro.html" target="_blank"&gt;http://support.sas.com/techsup/service_intro.html&lt;/A&gt;'&lt;BR /&gt;debug&lt;BR /&gt;;"&amp;nbsp; which gave no output at all!&lt;/P&gt;
&lt;P&gt;What is the "Bad request" error? And Can I fix it?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;The macro I used:&lt;/P&gt;
&lt;P&gt;*Create empty data set to append all distances;&lt;BR /&gt;data drdist;&lt;BR /&gt;run; &lt;BR /&gt;%macro ShortDrDist(j=);&lt;BR /&gt;*Create loop to access each observation;&lt;BR /&gt;%do i=1 %to &amp;amp;j;&lt;BR /&gt;*Assign macro variables needed;&lt;BR /&gt;data _null_;&lt;BR /&gt;set AddressY;&lt;BR /&gt;if _n_=&amp;amp;i then do;&lt;BR /&gt;call symput('addr1',trim(strip(Address1)));&lt;BR /&gt;call symput('addr2',trim(strip(Address2)));&lt;BR /&gt;call symput('referhid',referhid);&lt;BR /&gt;call symput('hospid',hospid);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;*Find Road distances;&lt;BR /&gt;filename gmaps url&lt;BR /&gt;"&lt;A href="http://maps.google.com/maps?daddr=&amp;amp;addr1.%nrstr(&amp;amp;saddr)=&amp;amp;addr2" target="_blank"&gt;http://maps.google.com/maps?daddr=&amp;amp;addr1.%nrstr(&amp;amp;saddr)=&amp;amp;addr2&lt;/A&gt;";&lt;BR /&gt;data drdistX&amp;amp;i (drop=sitecode idrivdist rdstart);&lt;BR /&gt;infile gmaps recfm=f lrecl=1000 end=eof;&lt;BR /&gt;input sitecode $1000.;&lt;BR /&gt;referhid="&amp;amp;referhid";&lt;BR /&gt;hospid="&amp;amp;hospid";&lt;BR /&gt;AddStart=tranwrd(tranwrd("&amp;amp;addr1","+"," "),",",", ");&lt;BR /&gt;AddEnd=tranwrd(tranwrd("&amp;amp;addr2","+"," "),",",", ");&lt;BR /&gt;if find(sitecode,'miles');&lt;BR /&gt;idrivdist=find(sitecode,'miles');&lt;BR /&gt;rdstart=idrivdist-1;&lt;BR /&gt;drivdist=input(compress(scan(substr(sitecode,1,rdstart),1,&lt;BR /&gt;' "','bc'),','),best12.);&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=drdistX&amp;amp;i; by drivdist; run;&lt;BR /&gt;data drdist&amp;amp;i;&lt;BR /&gt;set drdistX&amp;amp;i;&lt;BR /&gt;by drivdist;&lt;BR /&gt;if _n_=1;&lt;BR /&gt;run;&lt;BR /&gt;data drdist;&lt;BR /&gt;set drdist&lt;BR /&gt;drdist&amp;amp;i;&lt;BR /&gt;if drivdist^=.;&lt;BR /&gt;label AddStart='Starting Address'&lt;BR /&gt;AddEnd='Ending Address'&lt;BR /&gt;drivdist='Shortest Driving Distance (miles)'&lt;BR /&gt;referhid='Referring Hospital'&lt;BR /&gt;hospid='Destination Hospital';&lt;BR /&gt;run;&lt;BR /&gt;filename gmaps clear;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%ShortDrDist(j=&amp;amp;obsnum);&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 19:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918303#M361726</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-28T19:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ERROR: Bad request. Use the debug option for more info.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918309#M361730</link>
      <description>&lt;P&gt;Since you are running this in a number of macros set OPTIONS MPRINT;&lt;/P&gt;
&lt;P&gt;then run the code and show us the LOG with the entire error message in the context of the code generated by the macro.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 20:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918309#M361730</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-02-28T20:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ERROR: Bad request. Use the debug option for more info.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918312#M361731</link>
      <description>Run the macro with the macro debugging options and check your log. &lt;BR /&gt;&lt;BR /&gt;options mprint mlogic;&lt;BR /&gt;&lt;BR /&gt;Bad request sounds like a response from the Google site, ie a bad URL request was passed to the filename function.</description>
      <pubDate>Wed, 28 Feb 2024 20:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918312#M361731</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-02-28T20:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ERROR: Bad request. Use the debug option for more info.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918314#M361732</link>
      <description>&lt;P&gt;This is what I got:&lt;/P&gt;
&lt;P&gt;MPRINT(SHORTDRDIST): *Find Road distances;&lt;BR /&gt;MPRINT(SHORTDRDIST): filename gmaps url "&lt;A href="http://maps.google.com/maps?daddr=747" target="_blank"&gt;http://maps.google.com/maps?daddr=747&lt;/A&gt; Broadway+Seattle+WA+98122&amp;amp;saddr=325 9th&lt;BR /&gt;Ave+Seattle+WA+98104-2420";&lt;BR /&gt;MPRINT(SHORTDRDIST): data drdistX1 (drop=sitecode idrivdist rdstart);&lt;BR /&gt;MPRINT(SHORTDRDIST): infile gmaps recfm=f lrecl=1000 end=eof;&lt;BR /&gt;MPRINT(SHORTDRDIST): input sitecode $1000.;&lt;BR /&gt;MPRINT(SHORTDRDIST): referhid=" 1";&lt;BR /&gt;MPRINT(SHORTDRDIST): hospid=" 29";&lt;BR /&gt;MPRINT(SHORTDRDIST): AddStart=tranwrd(tranwrd("747 Broadway+Seattle+WA+98122","+"," "),",",", ");&lt;BR /&gt;MPRINT(SHORTDRDIST): AddEnd=tranwrd(tranwrd("325 9th Ave+Seattle+WA+98104-2420","+"," "),",",", ");&lt;BR /&gt;MPRINT(SHORTDRDIST): if find(sitecode,'miles');&lt;BR /&gt;MPRINT(SHORTDRDIST): idrivdist=find(sitecode,'miles');&lt;BR /&gt;MPRINT(SHORTDRDIST): rdstart=idrivdist-1;&lt;BR /&gt;MPRINT(SHORTDRDIST): drivdist=input(compress(scan(substr(sitecode,1,rdstart),1, ' "','bc'),','),best12.);&lt;BR /&gt;MPRINT(SHORTDRDIST): run;&lt;/P&gt;
&lt;P&gt;ERROR: Bad request. Use the debug option for more info.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.DRDISTX1 may be incomplete. When this step was stopped there were 0 observations and 5 variables.&lt;BR /&gt;WARNING: Data set WORK.DRDISTX1 was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.59 seconds&lt;BR /&gt;cpu time 0.54 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 20:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918314#M361732</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-28T20:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ERROR: Bad request. Use the debug option for more info.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918332#M361738</link>
      <description>&lt;P&gt;Thanks for sharing the MPRINT log.&amp;nbsp; Often a next good step is to copy the SAS code shown in the log, and replicate the problem with a simple step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This step replicates the problem:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename gmaps url 'http://maps.google.com/maps?daddr=747 Broadway+Seattle+WA+98122&amp;amp;saddr=325 9th+Ave+Seattle+WA+98104-2420';

data drdistX1 ;
infile gmaps recfm=f lrecl=1000 end=eof debug;
input sitecode $1000.;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log is:&lt;/P&gt;
&lt;PRE&gt;52   filename gmaps url 'http://maps.google.com/maps?daddr=747 Broadway+Seattle+WA+98122&amp;amp;saddr=325 9th+Ave+Seattle+WA+98104-2420';
53
54   data drdistX1 ;
55   infile gmaps recfm=f lrecl=1000 end=eof debug;
56   input sitecode $1000.;
57   run ;

NOTE: &amp;gt;&amp;gt;&amp;gt; GET /maps?daddr=747 Broadway+Seattle+WA+98122&amp;amp;saddr=325 9th+Ave+Seattle+WA+98104-2420 HTTP/1.0
NOTE: &amp;gt;&amp;gt;&amp;gt; Host: maps.google.com
NOTE: &amp;gt;&amp;gt;&amp;gt; Accept: */*
NOTE: &amp;gt;&amp;gt;&amp;gt; Accept-Language: en
NOTE: &amp;gt;&amp;gt;&amp;gt; Accept-Charset: iso-8859-1,*,utf-8
NOTE: &amp;gt;&amp;gt;&amp;gt; User-Agent: SAS/URL
NOTE: &amp;gt;&amp;gt;&amp;gt;
NOTE: &amp;lt;&amp;lt;&amp;lt; HTTP/1.0 400 Bad Request
NOTE: &amp;lt;&amp;lt;&amp;lt; Content-Type: text/html; charset=UTF-8
NOTE: &amp;lt;&amp;lt;&amp;lt; Referrer-Policy: no-referrer
NOTE: &amp;lt;&amp;lt;&amp;lt; Content-Length: 1555
NOTE: &amp;lt;&amp;lt;&amp;lt; Date: Wed, 28 Feb 2024 21:56:49 GMT
NOTE: &amp;lt;&amp;lt;&amp;lt;
ERROR: Bad request. Use the debug option for more info.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.DRDISTX1 may be incomplete.  When this step was stopped there were 0 observations and 1 variables.
WARNING: Data set WORK.DRDISTX1 was not replaced because this step was stopped.
&lt;/PRE&gt;
&lt;P&gt;It looks like google doesn't olike the space characters in the URL, e.g. the space between 747 and Broadway. If you replace them with +, it works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename gmaps url 'http://maps.google.com/maps?daddr=747+Broadway+Seattle+WA+98122&amp;amp;saddr=325+9th+Ave+Seattle+WA+98104-2420';

data drdistX1 ;
infile gmaps recfm=f lrecl=1000 end=eof debug;
input sitecode $1000.;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log is:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;64   filename gmaps url 'http://maps.google.com/maps?daddr=747+Broadway+Seattle+WA+98122&amp;amp;saddr=325+9th+Ave+Seattle+WA+98104-2420';
65
66   data drdistX1 ;
67   infile gmaps recfm=f lrecl=1000 end=eof ;
68   input sitecode $1000.;
69   run ;

NOTE: The infile GMAPS is:
      Filename=http://maps.google.com/maps?daddr=747+Broadway+Seattle+WA+98122&amp;amp;saddr=325+9th+Ave+Seattle+WA+98104-2420,
      Local Host Name=
      Local Host IP addr=
      Service Hostname Name=
      Service IP addr=
      Service Name=N/A,Service Portno=443,Lrecl=1000,
      Recfm=Fixed

NOTE: 171 records were read from the infile GMAPS.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.DRDISTX1 has 170 observations and 1 variables.
&lt;/PRE&gt;
&lt;P&gt;I didn't test the whole macro, or even the whole data step.&amp;nbsp; But fixing the URL at least allows the infile statement to work in scraping the page.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, Mike Raithel wrote a paper on scraping data from google maps, might be a helpful resource for you:&lt;BR /&gt;&lt;A href="https://www.basug.org/_files/ugd/6fce8c_964ee9ecca2d4def95d523ccef5b9465.pdf" target="_blank"&gt;https://www.basug.org/_files/ugd/6fce8c_964ee9ecca2d4def95d523ccef5b9465.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;He presented it as a webinar for BASUG, the recording is:&lt;BR /&gt;&lt;A href="https://www.basug.org/videos?wix-vod-video-id=4ffd50aeee284b1ca2a7c3ef5a91790e&amp;amp;wix-vod-comp-id=comp-klv807gt" target="_blank"&gt;https://www.basug.org/videos?wix-vod-video-id=4ffd50aeee284b1ca2a7c3ef5a91790e&amp;amp;wix-vod-comp-id=comp-klv807gt&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 22:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918332#M361738</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-02-28T22:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ERROR: Bad request. Use the debug option for more info.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918333#M361739</link>
      <description>Thank you so much. I figured the issue had to do with address formatting. much appreciate your kind support</description>
      <pubDate>Wed, 28 Feb 2024 22:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ERROR-Bad-request-Use-the-debug-option-for-more-info/m-p/918333#M361739</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-28T22:11:40Z</dc:date>
    </item>
  </channel>
</rss>

