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

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:


/* Assign a JSON library to the HTTP response */
libname space JSON 'resp';
/* Print result, dropping automatic ordinal metadata */
title "Who is in space right now? (as of &sysdate)";
proc print data=space.people (drop=ordinal:);

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";
proc contents data=qlib._all_;

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)









Accepted Solutions
Quartz | Level 8

I solve the problem!

There was <CR><LF> in the first row.

Using another file without work.


Thanks for you attention!



View solution in original post

Super User

What is in the first line of the JSON file?

Quartz | Level 8

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:


Quartz | Level 8

I solve the problem!

There was <CR><LF> in the first row.

Using another file without work.


Thanks for you attention!



Super User

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. 

Quartz | Level 8

I think the problem with Chris code is in http. I got the same error with this code:


filename resp temp;

proc http

proc contents data=resp._all_;



Barite | Level 11
You might want to take a look at;326f83bd.1612c

fro a related solution.

The code can run as is in IML


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


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
  • 6 replies
  • 3 in conversation