I´ve been trying to use SAS to import a database extracted through curl, but couldn´t figure how to pass the --data statement.
My curl command is:
curl --data "format=csv&includeColumnHeaders=1" --header "X-RJM-API-Key: <my-api-key>" https://api.rjmetrics.com/0.1/figure/<my-table-id>/export --ssl-no-revoke
I´ve tryied proc http method, but without success.
Any suggestions?
Try something like this:
filename result "/path-to-new-csv.csv";
proc http
url="https://api.rjmetrics.com/0.1/figure/<my-table-id>/export"
in = "format=csv&includeColumnHeaders=1"
out = result;
headers
"X-RJM-API-Key" = "<my-api-key>";
run;
First, make sure you can get to the internet from your SAS session. Run this test. You might need to specify a proxy host.
For the SSL check, you might add this statement before the run;
sslparms "sslreqcert"="allow";
The SSLPARMS statement can help specify behavior for verifying certificates.
Oh, and as far as getting a data set instead -- quickest way is PROC IMPORT after your step:
proc import
datafile="path-to-csv-result.csv"
out=work.result
dbms=CSV;
run;
A DATA step is more flexible to read CSV, but requires you know something about its structure.
I've tried sslreqcert and still dont works..
What error are you getting? The same HTTP 403?
Just noticed in the code you said you tried you had two IN= option specified. You need just one IN=, like this:
filename result temp;
proc http
url="https://api.rjmetrics.com/0.1/figure/11111/export"
in = "format=csv&includeColumnHeaders=1"
out=result;
headers "X-RJM-API-Key" = "11111111";
debug level=3;
run;
And did you test PROC HTTP in general as I suggested? Is that working?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: