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

Dear Experts,

 

I have a problem using SAS API request.

 

tried the example from  https://www.lexjansen.com/pharmasug/2017/AD/PharmaSUG-2017-AD13.pdf

 

filename eqty "C:\PHARMSUG\EnergyQuantityIndex.json" lrecl=32000;

 

proc http url='http://www.bea.gov/api/data?&UserID=my-user API key&method=GETDATASETLIST&ResultFormat=JSON&'

method='get' out=eqty

ct="application/json";

run;

 

but it got the following error message.

ERROR: Unable to load transient module (Bridge failure).

NOTE: The SAS System stopped processing this step because of errors.

21 proc http

21 ! url='http://www.bea.gov/api/data?&UserID=xxxxxxxx-xxxxxxx-xxxxxxxxx&method=GETDATAS

21 ! ETLIST&ResultFormat=JSON&'

22 method='get' out=eqty

23 ct="application/json";

24 run;

 

can you help me to resolve the error message.

Current version: 9.04.01M5P091317

 

thanks,

kesete

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

@tekish - Either your version of SAS isn't 9.4m4 or higher (but you say it's m5, so that should be okay), OR there is an installation issue.  That's indicated by your first post -- did you check the SAS Note I referenced?

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

7 REPLIES 7
ChrisHemedinger
Community Manager

Update: here's a SAS Note that might apply to you: http://support.sas.com/kb/61/513.html

 

Once you've followed the steps in the SAS note, try the simple test program that I shared here.  That will verify that you can use PROC HTTP to reach a public web service, retrieve a response, and parse the output.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
tekish
Quartz | Level 8

Chris, I'm trying to run this code in 9.4_M5 , but getting the error below. What am I missing?

filename resp temp;

/* Neat service from Open Notify project */
proc http
url="http://api.open-notify.org/astros.json"
method= "GET"
out=resp;
run;

/* Assign a JSON library to the HTTP response */
libname space JSON fileref=resp;

/* Print result, dropping automatic ordinal metadata */
title "Who is in space right now? (as of &sysdate)";
proc print data=space.people (drop=ordinal:);
run;

ERROR:

ERROR: The JSON engine cannot be found.
ERROR: Error in the LIBNAME statement.
56
57 /* Print result, dropping automatic ordinal metadata */
58 title "Who is in space right now? (as of &sysdate)";
59 proc print data=space.people (drop=ordinal:);
ERROR: Libref SPACE is not assigned.

ChrisHemedinger
Community Manager

@tekish - Either your version of SAS isn't 9.4m4 or higher (but you say it's m5, so that should be okay), OR there is an installation issue.  That's indicated by your first post -- did you check the SAS Note I referenced?

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
tekish
Quartz | Level 8

Chris,

 

I checked this reference check the SAS Note I referenced?. It is already installed my SAS current version.

tekish
Quartz | Level 8

Chris,

 

 the Below code runs with out any error.

 

Filename datain url 'http://chronicdata.cdc.gov/resource/dttw-5yxu.csv?topic=Overall%20Health&break_out=Overall';

 

 

proc import datafile=datain out=cdc_brfss_overall_health dbms=csv replace;

getnames=yes;

 

/* The following two procs would print out the schema and data itself, respectively */

/* proc contents; */

/* proc print data=cdc_brfss_excellent_health; */

/* remove non-states from the dataset */

data cdc_brfss_overall_health;

set cdc_brfss_overall_health;

if Locationabbr = 'UW' then delete;

if Locationabbr = 'US' then delete;

run;

 

/* Create a dataset that only has "Excellent" responses */

data cdc_brfss_excellent_health;

set cdc_brfss_overall_health;

if Response ^= 'Excellent' then delete;

run;

 

/* Sort the dataset (this is required for the non-paneled box plot coming up to work) */

proc sort data=cdc_brfss_excellent_health

out=cdc_brfss_excellent_health;

by Year;

 

 

/* Show a box plot with Year on the X-axis and the data_value on the Y-axis - excellent responses only */

title 'CDC BRFSS asked "How is your general health?"';

title2 'Data source: https://chronicdata.cdc.gov/d/dttw-5yxu';

proc boxplot data=cdc_brfss_excellent_health;

plot Data_value*Year /

BOXSTYLE=SCHEMATICID odstitle=title odstitle2=title2;

label Data_value = 'Crude % of Respondents Who Answered "Excellent"';

id Locationabbr;

 

/* Show a paneled box plot where each panel is a Response (excellent, very good, fair, poor) */

proc sgpanel data=cdc_brfss_overall_health;

panelby Response / novarname columns=5;

vbox Data_value / category=year datalabel=Locationabbr;

label Data_value = 'Crude Percentage'

 

run;

 

/* Show a frequency table to see how many data points each state has */

/* proc freq data=cdc_brfss_excellent_health;

tables Locationabbr / nocum;

run; */

 

thanks

ChrisHemedinger
Community Manager

I'm glad that you have something working.  If you can't use PROC HTTP (which would be a better/faster method for using these APIs), then you probably still need to address the issue I shared in the SAS note I referenced.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
tekish
Quartz | Level 8

Chris,

 

It works with out any error.

 

thanks,

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 7 replies
  • 5159 views
  • 4 likes
  • 2 in conversation