SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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