BookmarkSubscribeRSS Feed
BigD
Calcite | Level 5

Hello,

I've been using SAS to scrape a lot of "easy" web sites. Now I have one where I have to submit a location (province) into a form then read in the information. To further complicate matters, the return results are listed say 20 at a time, so I need to span the result pages. The proc http documentations doesn't really help. Anyone have a basic working example I can build on.

Thanks,

Bruce

1 REPLY 1
mich1
Obsidian | Level 7

​Here is an example of a complex API transaction using SAS and PROC HTTP

/*POST A REQUEST FOR SURVEY DATA*/
/****************************************************************************/
/* Qualtrics API Request to get export of survey response data
/****************************************************************************/
filename rsp temp;  
proc http
method= "POST"
in='{"format" : "csv","surveyId" : "yoursurveyID"}'
out=rsp;
headers
"X-API-Token"="yourAPItoken"
"Content-Type"="application/json"
;
run; 
libname RSP JSON fileref=rsp;
 
/*Check Status of request*/
filename dwnld temp;
proc http
method= "GET"
out=dwnld;
headers 
"X-API-Token"="yourAPItoken";
run;
libname dwnld JSON fileref=dwnld;
 
/*Download request - You can view json dwnld for status and filename (same as yourresultID above)*/
filename dwnld '/yourPathHere/GOTDATA';
proc http
method= "GET"
out=dwnld;
headers 
"X-API-Token"="yourAPItoken";
run;
Bread Crumbs and Circuses for All

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 756 views
  • 0 likes
  • 2 in conversation