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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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