Your SAS programs, embedded in web apps and elsewhere

Stored process with url

Reply
Occasional Contributor
Posts: 18

Stored process with url

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;

PROC Star
Posts: 1,324

Re: Stored process with url

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

Occasional Contributor
Posts: 18

Re: Stored process with url

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

Thank you for your reply!

SAS Employee
Posts: 170

Re: Stored process with url

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

PROC Star
Posts: 1,324

Re: Stored process with url

Posted in reply to Darrell_sas

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.

Occasional Contributor
Posts: 18

Re: Stored process with url

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.

SAS Employee
Posts: 170

Re: Stored process with url

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

Just the legal part of things. 

Occasional Contributor
Posts: 18

Re: Stored process with url

Posted in reply to Darrell_sas

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?

Occasional Contributor
Posts: 18

Re: Stored process with url

Posted in reply to Darrell_sas

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

SAS Employee
Posts: 170

Re: Stored process with url

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>

Frequent Contributor
Posts: 106

Re: Stored process with url

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.

Ask a Question
Discussion stats
  • 10 replies
  • 1490 views
  • 3 likes
  • 4 in conversation