Hello,
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."
I used this code to check "filename gmaps url 'http://support.sas.com/techsup/service_intro.html' debug ;" which gave no output at all!
What is the "Bad request" error? And Can I fix it?
Thanks.
The macro I used:
*Create empty data set to append all distances; data drdist; run; %macro ShortDrDist(j=); *Create loop to access each observation; %do i=1 %to &j; *Assign macro variables needed; data _null_; set AddressY; if _n_=&i then do; call symput('addr1',trim(strip(Address1))); call symput('addr2',trim(strip(Address2))); call symput('referhid',referhid); call symput('hospid',hospid); end; run; *Find Road distances; filename gmaps url "http://maps.google.com/maps?daddr=&addr1.%nrstr(&saddr)=&addr2"; data drdistX&i (drop=sitecode idrivdist rdstart); infile gmaps recfm=f lrecl=1000 end=eof; input sitecode $1000.; referhid="&referhid"; hospid="&hospid"; AddStart=tranwrd(tranwrd("&addr1","+"," "),",",", "); AddEnd=tranwrd(tranwrd("&addr2","+"," "),",",", "); if find(sitecode,'miles'); idrivdist=find(sitecode,'miles'); rdstart=idrivdist-1; drivdist=input(compress(scan(substr(sitecode,1,rdstart),1, ' "','bc'),','),best12.); run; proc sort data=drdistX&i; by drivdist; run; data drdist&i; set drdistX&i; by drivdist; if _n_=1; run; data drdist; set drdist drdist&i; if drivdist^=.; label AddStart='Starting Address' AddEnd='Ending Address' drivdist='Shortest Driving Distance (miles)' referhid='Referring Hospital' hospid='Destination Hospital'; run; filename gmaps clear; %end; %mend; %ShortDrDist(j=&obsnum);
... View more