BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
A_SAS_Man
Pyrite | Level 9

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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?


 

View solution in original post

1 REPLY 1
Reeza
Super User

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?


 

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

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 3396 views
  • 0 likes
  • 2 in conversation