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!
* 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...;
* 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...;
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.