02-19-2018 10:26 AM
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&'
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 ! ETLIST&ResultFormat=JSON&'
22 method='get' out=eqty
can you help me to resolve the error message.
Current version: 9.04.01M5P091317
02-19-2018 01:21 PM
02-19-2018 12:26 PM - edited 02-19-2018 12:41 PM
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.
02-19-2018 01:07 PM
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 */
/* 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;
ERROR: The JSON engine cannot be found.
ERROR: Error in the LIBNAME statement.
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.
02-19-2018 01:21 PM
02-19-2018 03:08 PM - edited 02-19-2018 03:08 PM
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;
/* 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 */
if Locationabbr = 'UW' then delete;
if Locationabbr = 'US' then delete;
/* Create a dataset that only has "Excellent" responses */
if Response ^= 'Excellent' then delete;
/* Sort the dataset (this is required for the non-paneled box plot coming up to work) */
proc sort data=cdc_brfss_excellent_health
/* 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"';
/* 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'
/* Show a frequency table to see how many data points each state has */
/* proc freq data=cdc_brfss_excellent_health;
tables Locationabbr / nocum;
02-20-2018 07:38 AM
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.
Need further help from the community? Please ask a new question.