I am attempting to pull data from a public API using proc http. I will eventually want to feed a file with multiple values to the API and collect the response, but for now I am just trying to understand the mechanics of accessing it so I'm using a static URL. I'm having trouble figuring out how to view my output below.
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;
This appears to run without error, and as I understand it should generate a .json file, but I'm not sure how I can view that/parse it into something useful. I have been getting information on the API from the following source:
https://rxnav.nlm.nih.gov/RxNormAPIs.html#
How can I take my json output (resp) and convert it into a datafile? How can I tell if my call to the API is actually working?
It looks like the response is XML, not JSON.
filename resp '/home/XXXXXXX/Demo1/demo.xml';
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;
libname myfiles xml '/home/XXXXXXX/Demo1/demo.xml';
data ndcstatus;
set myfiles.ndcstatus;
run;
proc print;run;
@A_SAS_Man wrote:
I am attempting to pull data from a public API using proc http. I will eventually want to feed a file with multiple values to the API and collect the response, but for now I am just trying to understand the mechanics of accessing it so I'm using a static URL. I'm having trouble figuring out how to view my output below.
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;This appears to run without error, and as I understand it should generate a .json file, but I'm not sure how I can view that/parse it into something useful. I have been getting information on the API from the following source:
https://rxnav.nlm.nih.gov/RxNormAPIs.html#
How can I take my json output (resp) and convert it into a datafile? How can I tell if my call to the API is actually working?
It looks like the response is XML, not JSON.
filename resp '/home/XXXXXXX/Demo1/demo.xml';
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;
libname myfiles xml '/home/XXXXXXX/Demo1/demo.xml';
data ndcstatus;
set myfiles.ndcstatus;
run;
proc print;run;
@A_SAS_Man wrote:
I am attempting to pull data from a public API using proc http. I will eventually want to feed a file with multiple values to the API and collect the response, but for now I am just trying to understand the mechanics of accessing it so I'm using a static URL. I'm having trouble figuring out how to view my output below.
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;This appears to run without error, and as I understand it should generate a .json file, but I'm not sure how I can view that/parse it into something useful. I have been getting information on the API from the following source:
https://rxnav.nlm.nih.gov/RxNormAPIs.html#
How can I take my json output (resp) and convert it into a datafile? How can I tell if my call to the API is actually 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 25. 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.