DATA Step, Macro, Functions and more

Confusion errors in libname Json

Accepted Solution Solved
Reply
Contributor
Posts: 53
Accepted Solution

Confusion errors in libname Json

[ Edited ]

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

 

 

 

 

 


Accepted Solutions
Solution
‎12-17-2016 07:29 AM
Contributor
Posts: 53

Re: Confusion errors in libname Json

Posted in reply to AndersBergquist

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


All Replies
Super User
Posts: 19,822

Re: Confusion errors in libname Json

Posted in reply to AndersBergquist

What is in the first line of the JSON file?

Contributor
Posts: 53

Re: Confusion errors in libname Json

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

 

Solution
‎12-17-2016 07:29 AM
Contributor
Posts: 53

Re: Confusion errors in libname Json

Posted in reply to AndersBergquist

I solve the problem!

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

Using another file without work.

 

Thanks for you attention!

 

/Anders

Super User
Posts: 19,822

Re: Confusion errors in libname Json

Posted in reply to AndersBergquist

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. 

Contributor
Posts: 53

Re: Confusion errors in libname Json

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;

 

 

Valued Guide
Posts: 505

Re: Confusion errors in libname Json

Posted in reply to AndersBergquist
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
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 628 views
  • 0 likes
  • 3 in conversation