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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 824 views
  • 0 likes
  • 2 in conversation