BookmarkSubscribeRSS Feed
Alonzo
Calcite | Level 5

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;

10 REPLIES 10
Quentin
Super User

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?)

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Alonzo
Calcite | Level 5

I got an error when I create the stored process. SAS processes run well under SAS EG.

Thank you for your reply!

Darrell_sas
SAS Employee

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

Quentin
Super User

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.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Alonzo
Calcite | Level 5

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.

Darrell_sas
SAS Employee

No, it has nothing to do with the Google license. 

Just the legal part of things. 

Alonzo
Calcite | Level 5

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?

Alonzo
Calcite | Level 5

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

Darrell_sas
SAS Employee

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>

boemskats
Lapis Lazuli | Level 10

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 2604 views
  • 3 likes
  • 4 in conversation