I am trying to import an json-file to sas with the new libname statement. I got errors both when I test the submited code in this sas blog: http://blogs.sas.com/content/sasdummy/#fn
/* Assign a JSON library to the HTTP response */
libname space JSON 'resp';
run;
/* Print result, dropping automatic ordinal metadata */
title "Who is in space right now? (as of &sysdate)";
proc print data=space.people (drop=ordinal:);
run;
And got this error: "ERROR: Libref SPACE is not assigned.".
I also test this code:
ibname qlib json "D:\Data\SAS\SCB API\AKU_ALOS_FRAGA.JSON";
run;
proc contents data=qlib._all_;
run;
and got this error:
(ERROR: Invalid JSON in input near line 1 column 1: Encountered an illegal character.
ERROR: Error in the LIBNAME statement.)
My system version is;
NOTE: Copyright (c) 2002-2012 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1M4)
Licensed to , Site .
NOTE: This session is executing on the X64_10PRO platform.
NOTE: Updated analytical products:
SAS/STAT 14.2
SAS/ETS 14.2
NOTE: Additional host information: X64_10PRO WIN 10.0.14393 Workstation
I think I have the latest version of SAS. I downloaded it from SAS yesterday and the text indicated it.
What I do no know is if libname json requiere an additional license. I have try to figured it out, but do not find it.
My questions is.
1. Can I got libname json to work on this computer?
2. What have got wrong with my programs?
My final goal is to import data from Statistic Sweden, SCB, with there api. (They have the same api at as least Statistic Finland)
/Anders
I solve the problem!
There was <CR><LF> in the first row.
Using another file without work.
Thanks for you attention!
/Anders
What is in the first line of the JSON file?
The first caracter is; {
I enclose the json file but I have to chance the typer from .json to .txt.
You can also find an other file like this at Statistics Swedens description of the API:
http://www.scb.se/en_/About-us/Open-data-API/API-for-the-Statistical-Database-/
I solve the problem!
There was <CR><LF> in the first row.
Using another file without work.
Thanks for you attention!
/Anders
Try the exact code from Chris blog. If it works it's either the file or code, if it doesn't it's a system/license problem.
9.4TS1M4 is the latest version.
I think the problem with Chris code is in http. I got the same error with this code:
filename resp temp;
proc http
url="http://api.open-notify.org/astros.json"
method="GET"
out=resp;
run;
proc contents data=resp._all_;
run;
You might want to take a look at
https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;326f83bd.1612c
fro a related solution.
The code can run as is in IML
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.