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: 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

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AndersBergquist
Quartz | Level 8

I solve the problem!

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

Using another file without work.

 

Thanks for you attention!

 

/Anders

View solution in original post

6 REPLIES 6
Reeza
Super User

What is in the first line of the JSON file?

AndersBergquist
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:

http://www.scb.se/en_/About-us/Open-data-API/API-for-the-Statistical-Database-/

 

AndersBergquist
Quartz | Level 8

I solve the problem!

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

Using another file without work.

 

Thanks for you attention!

 

/Anders

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

AndersBergquist
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
	url="http://api.open-notify.org/astros.json"
	method="GET"
	out=resp;
run;

proc contents data=resp._all_;
run;

 

 

rogerjdeangelis
Barite | Level 11
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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3184 views
  • 0 likes
  • 3 in conversation