BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Hello,

 

I am a new user of proc http in SAS.

I have tried the code below and it works

 

options set=SSLREQCERT="allow";
filename resp temp;
 
PROC HTTP
    METHOD="GET"
    URL= 'https://ca1.qualtrics.com/API/v3/surveys'
    OUT=resp;
    headers
    'x-api-token'= '***************ddssXDlLVfJUwJOJfD74l0sc1';
run;
 
/* Let the JSON engine do its thing */
libname posts JSON fileref=resp;
title "Automap of JSON data";
 
/* examine resulting tables/structure */
proc datasets lib=posts; quit;
proc print data=posts.alldata; run;

data Basic_survey_info (drop=ordinal_result ordinal_elements);
set posts.result_elements;
obs=ordinal_elements;
run;

From the table Basic_Survey_info, one of the survey id is equal to SV_ahhZznQMwSAyrGK

 

With this information I would like to execute the script below but in SAS. How to do that ?

 

curl --request POST \
--header 'Content-Type: application/json' \
--header 'X-API-TOKEN: ' \
--data '{
"format": "csv"
}'
 
Whats the url will look like when you the surveyId by it's value ?
 
I have tried this piece of code 
options set=SSLREQCERT="allow";
filename resp TEMP;
%let SurveyId=SV_ahhZznQMwSAyrGK;
proc http
   url="https://ca1.qualtrics.com/API/v3/surveys/&SurveyId./export-responses"
   out=resp;
 headers   
   'x-api-token'= '***********ssXDlLVfJUwJOJfD74l0sc1'
   'Content-Type'='application/json';
run;
but I am strill getting an error 404
 
NOTE: 404 Not Found
NOTE: PROCEDURE HTTP used (Total process time):
real time 0.30 seconds
cpu time 0.00 seconds
 
More over, how do we convert the information 
data '{
"format": "csv" in SAS
 
 
1 REPLY 1
AlanC
Barite | Level 11

I would start with using POST vs GET in your call.

 

Some sample code:

 

filename resp temp;
filename outPP temp;

filename sasPgm 'C:\repos\StoredPrograms\DemoStoredProgram.sas';

/*===================================================================== ;
* Executes SAS code
* curl -X POST "http://ina-442tdh2.acmeinc.com:9000/Sas/ExecuteSasProgramFile?
* sasMachine=Any&email=alan.churchill%40acmeinc.com"
* -H "accept: text/plain"
* -H "Content-Type: multipart/form-data"
* -F "sasFile=@DemoStoredProgram.sas;type=application/x-sas"
*=====================================================================*/ ;

proc http
url = 'http://ina-442tdh2.acmeinc.com:9000/Sas/ExecuteSasProgramFile?sasMachine=Any&email=alan.churchill%40...'
method="POST"
in = sasPgm
ct = "multipart/form-data"
;
headers "Accept"="text/plain"
;
run;

https://github.com/savian-net

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!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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