I'd like to use the SAS libname JSON engine instead of PROC GROOVY to import the JSON file I get from the Twitter API. I am running SAS 9.4M4 on OpenSuse LEAP 42.3.
I followed Falko Schulz's description in how to access the Twitter API and everthing worked out fine. Up to the point at which I wanted to import the JSON file into SAS. So the last working line of code is:
proc http method="get"
out=res headerin=hdrin
url="https://api.twitter.com/1.1/search/tweets.json?q=&TWEET_QUERY.%nrstr(&)count=1"
ct="application/x-www-form-urlencoded;charset=UTF-8";
run;
which yields a json-file in the file referenced with the filename "res".
Falko Schulz uses PROC GROOVY. In SAS 9.4M4, however, there is this mysterious JSON libname engine that makes life easier. And it works for simple JSON files. But not for the Twitter data. So having the JSON data from Twitter downloaded, using
libname test JSON filref=res;
gives me the following error:
Invalid JSON in input near line 1 column 751: Some code points did not transcode.
I suspected that something is wrong with the encoding of the files so I used a filename statement of the form:
filename res TEMP encoding="utf-8";
without luck...
I also tried to increase the record length
filename res TEMP encoding="utf-8" lrecl=1000000;
and played around with the record format... to no avail...
Can somebody help? What am I missing? How can I use the JSON engine in a LIBNAME statement without running into this error?
proc options option=encoding; run;
– Joe