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?


 

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!
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.

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