Hello,
I am developing a tool that calculate travel time between two points. For accurate calculation, I use Google map api.
In sas eg process, it works correctly. However, when I try to create storeprocess, I got an error message, Bad request. Use the debug option for more info.
Do you how I can fix this issue? The below is the code for use of google map.
Thank you.
--------------------------------------------------------------------------------------------------------------
data _null_;
nrec = &j;
set WORK.ORIGIN_DESTINATION_AP point=nrec;
call symputx('p2',put(LAT_LONG_DESTINATION,char20.));
call symputx('p1',put(LAT_LONG_ORIGIN,char20.));
stop;
run;
filename x url "http://maps.googleapis.com/maps/api/directions/xml?origin=&p1&destination=&p2";
data temp;
nrec = &j;
set WORK.ORIGIN_DESTINATION_AP point=nrec;
call symputx('a2',put(Demand_AP,char8.));
call symputx('a1',put(Source_AP,char8.));
* retain Source_AP &a1 Demand_AP &a2;
infile x lrecl=32000 pad;
input;
loc = find(_infile_,'<value>');
if loc ne 0 then
do;
text = substr(_infile_,11,50);
text = scan(text,1,'>');
/* select;
* calculate distance in mi;
when (find(text,'distance') ne 0) distance = input(scan(text,1),best.)/5280;
otherwise */
time = input(scan(text,1),best.);
* end;
end;
* Ddistance(i) = distance;
* Dtime(i) = time;
output;
keep Demand_AP Source_AP time;
* format time best.;
run;
filename x clear;
You get that error when you try to create the stored process? Or when you try to run it? If it happens when you run it, how are your running it (from inside EG or another client?)
I got an error when I create the stored process. SAS processes run well under SAS EG.
Thank you for your reply!
The use of Google Maps is heavily licensed. You cannot use a Google Maps service without it appearing on a map. In other words, you cannot use it without a Google Map and you cannot save off the results in SAS or any other product. See the Terms of Use.
https://developers.google.com/maps/terms
See section 10.1.1.H
Leonid Batkhan has a great series of blog posts on using google maps with SAS:
http://blogs.sas.com/content/sgf/author/leonidbatkhan/
If you get the error message when you try to create the stored process, then I would think it's not a problem with your SAS code. Are you able to create other stored processes? To create a stored process you need SAS BI with a metadata server etc etc, not just base SAS.
The stored process is working correctly without a macro function that finds data in Google Maps.
I will take a look at blogs that you suggest.
Thank you again for your advice.
No, it has nothing to do with the Google license.
Just the legal part of things.
Thank you for your comment.
I think the observed error (bad request) is nothing to do with license issue. Also, I can see the results of using Google Maps in the SAS Enterprise Guide.
Do you think I have an error in the stored process because of Google license?
Darrell,
Do you know how I can log on google account in SAS program?
I implemented google maps in SAS enterprise guide, but Google allow only limited number of use.
Thus, I purchased license, but I don't know how to log on my account in SAS.
Would you please explain how to do it?
Thanks
I haven't used a purchased version. I think now it is called Google Maps for Work. But I found the following page:
https://developers.google.com/maps/documentation/business/clientside/
And it says that you must use your client id:
<script src="https://maps.googleapis.com/maps/api/js?client=YOUR_CLIENT_ID&v=3.20"></script>
Hi Alonzo,
Does the application server that you execute your Stored Processes on have access to the outside world, in terms of making HTTP requests to http://maps.googleapis.com?
You may find that the code runs well from a local session on your desktop, as your system proxy is configured to allow your machine access to the outside world. However, I've seen many customer sites where the application servers have no access to the external internet, either via not having the proxy configured or having the access intentionally disabled. Keep in mind that when you register a Stored Process, the code runs on a remote application server. I suspect this is most likely the case here.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.