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

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