DATA Step, Macro, Functions and more

Does anyone have example code that uses Google's API?

Accepted Solution Solved
Reply
PROC Star
Posts: 7,473
Accepted Solution

Does anyone have example code that uses Google's API?

I want to submit a Google search, from SAS, probably using proc http.  However, as I've never done it, I'm not sure where to begin.  Yes, I already have an API key, but don't know what code to nest it in.  Basically, I just looking to do a search and trap all of the results in an output file.

Any help would be greatly appreciated!


Accepted Solutions
Solution
‎11-22-2011 05:02 PM
Trusted Advisor
Posts: 1,301

Does anyone have example code that uses Google's API?

* As far as I can tell, this are the minimum things you need to have a result sent;

* key - your API key;

* cx - goto your google APIs Console.  Click on the '?' button.  Click 'Try me out!'.  Grab the cx var from the spawned url;

* q - your search query;

filename in temp;

filename out temp;

data _null_;

  file in;

  input;

  put _infile_;

  datalines4;

key=myapikey&cx=mycxid&q=my+query

;;;;

run;

proc http in=in out=out url="https://www.googleapis.com/customsearch/v1" method="get"; run;

* because of issues with my installation I cannot use Proc HTTP, I should probably fix that, but as such I cannot actually test that this works in this context...;

View solution in original post


All Replies
Solution
‎11-22-2011 05:02 PM
Trusted Advisor
Posts: 1,301

Does anyone have example code that uses Google's API?

* As far as I can tell, this are the minimum things you need to have a result sent;

* key - your API key;

* cx - goto your google APIs Console.  Click on the '?' button.  Click 'Try me out!'.  Grab the cx var from the spawned url;

* q - your search query;

filename in temp;

filename out temp;

data _null_;

  file in;

  input;

  put _infile_;

  datalines4;

key=myapikey&cx=mycxid&q=my+query

;;;;

run;

proc http in=in out=out url="https://www.googleapis.com/customsearch/v1" method="get"; run;

* because of issues with my installation I cannot use Proc HTTP, I should probably fix that, but as such I cannot actually test that this works in this context...;

PROC Star
Posts: 7,473

Does anyone have example code that uses Google's API?

Matt, Very much appreciated!  I won't be able to test it until tomorrow or Thursday, but that got me exactly what I was missing.

Thanks again,

Art

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 216 views
  • 0 likes
  • 2 in conversation