BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
art297
Opal | Level 21

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!

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

* 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

2 REPLIES 2
FriedEgg
SAS Employee

* 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...;

art297
Opal | Level 21

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 820 views
  • 0 likes
  • 2 in conversation