Very interesting!
This is something I wanted to know more about anyway, so I played around with it a bit.
You didn't specify the exact format of your JSON text, so I "invented" the following, from a SAS paper that I reviewed:
{"firstName": "John", "lastName": "Smith", "age": 25}
When I run the following code, which creates a one-line file, it works:
%let DirRef = /home/me;
data _null_;
length OutLine $32767;
file "&DirRef./JSExample.json" lrecl=32767;
OutLine = '{"firstName": "John", "lastName": "Smith", "age": 25}'; put OutLine;
/* OutLine = '{"firstName": "Joho", "lastName": "Smiti", "age": 26}'; put OutLine; */
run;
filename jsonxmp "&DirRef./JSExample.json";
libname jstest JSON fileref=jsonxmp;
proc print data=jstest.root;
run;
However, when I run the following, which creates two lines:
%let DirRef = /home/cstkari/my_content;
data _null_;
length OutLine $32767;
file "&DirRef./JSExample.json" lrecl=32767;
OutLine = '{"firstName": "John", "lastName": "Smith", "age": 25}'; put OutLine;
OutLine = '{"firstName": "Joho", "lastName": "Smiti", "age": 26}'; put OutLine;
run;
filename jsonxmp "&DirRef./JSExample.json";
libname jstest JSON fileref=jsonxmp;
proc print data=jstest.root;
run;
it fails with the following error:
ERROR: Invalid JSON in input near line 2 column 2: Unexpected characters found after valid JSON text.
ERROR: Error in the LIBNAME statement.
Either the multi-line format isn't actually valid JSON, or SAS can't interpret a valid JSON format correctly.
Hope this helps!
Tom
... View more