<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Proc Json in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512737#M73103</link>
    <description>&lt;P&gt;Redshift accepted format is this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;{ "one": 1, "two": "Sports", "three": "MLB", "four": "Major League Baseball" }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; { "three": "NHL", "four": "National Hockey League", "one": 2, "two": "Sports" }&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Nov 2018 20:38:33 GMT</pubDate>
    <dc:creator>sundeep23</dc:creator>
    <dc:date>2018-11-13T20:38:33Z</dc:date>
    <item>
      <title>Proc Json to create newline-delimited JSON (JSONL)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512716#M73101</link>
      <description>&lt;P&gt;Hi SAS experts,&lt;/P&gt;
&lt;P&gt;I am trying to create a Json file with below format&amp;nbsp;&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;"col1":abc,&lt;/P&gt;
&lt;P&gt;"col2":bca&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;"col1":ccc,&lt;/P&gt;
&lt;P&gt;"col2":xcv&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;But when I use proc json I am getting the below output I dont want the beginning and end [ ] brackets and the comma separator between first and second&amp;nbsp; {} brackets .Appreciate any ideas. Thank you&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;"col1":abc,&lt;/P&gt;
&lt;P&gt;"col2":bca&lt;/P&gt;
&lt;P&gt;},&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;"col1":ccc,&lt;/P&gt;
&lt;P&gt;"col2":xcv&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;]&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 15:38:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512716#M73101</guid>
      <dc:creator>sundeep23</dc:creator>
      <dc:date>2018-11-14T15:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512736#M73102</link>
      <description>&lt;P&gt;Are you sure your wanted string is valid JSON syntax? Which software needs this format?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 20:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512736#M73102</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2018-11-13T20:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512737#M73103</link>
      <description>&lt;P&gt;Redshift accepted format is this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;{ "one": 1, "two": "Sports", "three": "MLB", "four": "Major League Baseball" }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; { "three": "NHL", "four": "National Hockey League", "one": 2, "two": "Sports" }&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 20:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512737#M73103</guid>
      <dc:creator>sundeep23</dc:creator>
      <dc:date>2018-11-13T20:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512739#M73105</link>
      <description>&lt;P&gt;That looks like JSONL (JSON Lines), not standard JSON. &lt;A href="http://jsonlines.org" target="_blank"&gt;http://jsonlines.org&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC JSON doesn't create that, as far as I know.&amp;nbsp; But you could create a JSON output for each record and append these together in a single file to generate the JSONL.&amp;nbsp; Depending on how many records you have and what you're trying to automate, this might be worthwhile.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 20:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512739#M73105</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-11-13T20:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512742#M73106</link>
      <description>&lt;P&gt;The JSON procedure writes the specified data to a file within a single JSON structure. Therefore you get as your output a JSON array containing 2 JSON objects. What you are asking for is to create a file containing 2 JSON objects. A single PROC JSON statement cannot produce what you desire. But note that the output you desire is not valid JSON. For one thing, the values assigned to “col1” and “col2” are strings and in JSON a string requires surrounding double quotes. Also, a JSON file contains a single JSON structure. When I put the contents of what you want in your JSON file into a JSON validator, like JSONLint, the validator says the file contains errors (even after making the column values proper JSON strings). &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Error: Parse error on line 4:&lt;/P&gt;
&lt;P&gt;...",&amp;nbsp;&amp;nbsp; "col2": "bca"} {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "col1": "ccc", "&lt;/P&gt;
&lt;P&gt;---------------------^&lt;/P&gt;
&lt;P&gt;Expecting 'EOF', '}', ',', ']', got '{'&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 20:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512742#M73106</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2018-11-13T20:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512746#M73107</link>
      <description>&lt;P&gt;As Chris notes, you could use multiple PROC JSON statements to produce multiple files each containing a single JSON object. This code will produce a single JSON object as you desire:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc json out='./test.out' nosastags pretty;
  write open object; 
    write values col1 abc; 
    write values col2 cba;
  write close;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, a full solution would probably require some dynamic coding to properly update the file name (most likely with an incremented number appended to the base name) and including the proper data for each object from what I assume is a data set.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 21:04:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512746#M73107</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2018-11-13T21:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512747#M73108</link>
      <description>&lt;P&gt;So essentially each line is a JSON object on its own. Proc JSON&amp;nbsp;always wants to have a valid JSON syntax for the complete file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe it is easier to write out the text using the DATA Step&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 21:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512747#M73108</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2018-11-13T21:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512756#M73109</link>
      <description>&lt;P&gt;Maybe something like this.&amp;nbsp; This generates a JSON output for each record in a data set, then appends all of those outputs together.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 set sashelp.class;
 call execute(catt('filename out "c:\temp\out',_n_,'.json";'));
 call execute('proc json out=out nosastags ;');
 call execute('export sashelp.class(obs='||_n_||' firstobs='||_n_||');');
 call execute('run;');
run;

data _null_;
 file "c:\temp\final.json" ;
 infile "c:\temp\out*.json";
 input;
 put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Nov 2018 21:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512756#M73109</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-11-13T21:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512763#M73110</link>
      <description>&lt;P&gt;Thanks Chris this is great. Below is the output. The only thing I need to worry about is the array container square brackets . Can those can be removed through&amp;nbsp;proc json or I need to get into file to replace using sed command&amp;nbsp; ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[{"Name":"Alfred","Sex":"M","Age":14,"Height":69,"Weight":112.5}]&lt;BR /&gt;[{"Name":"John","Sex":"M","Age":12,"Height":59,"Weight":99.5}]&lt;BR /&gt;[{"Name":"Joyce","Sex":"F","Age":11,"Height":51.3,"Weight":50.5}]&lt;BR /&gt;[{"Name":"Judy","Sex":"F","Age":14,"Height":64.3,"Weight":90}]&lt;BR /&gt;[{"Name":"Louise","Sex":"F","Age":12,"Height":56.3,"Weight":77}]&lt;BR /&gt;[{"Name":"Mary","Sex":"F","Age":15,"Height":66.5,"Weight":112}]&lt;BR /&gt;[{"Name":"Philip","Sex":"M","Age":16,"Height":72,"Weight":150}]&lt;BR /&gt;[{"Name":"Robert","Sex":"M","Age":12,"Height":64.8,"Weight":128}]&lt;BR /&gt;[{"Name":"Ronald","Sex":"M","Age":15,"Height":67,"Weight":133}]&lt;BR /&gt;[{"Name":"Thomas","Sex":"M","Age":11,"Height":57.5,"Weight":85}]&lt;BR /&gt;[{"Name":"William","Sex":"M","Age":15,"Height":66.5,"Weight":112}]&lt;BR /&gt;[{"Name":"Alice","Sex":"F","Age":13,"Height":56.5,"Weight":84}]&lt;BR /&gt;[{"Name":"Barbara","Sex":"F","Age":13,"Height":65.3,"Weight":98}]&lt;BR /&gt;[{"Name":"Carol","Sex":"F","Age":14,"Height":62.8,"Weight":102.5}]&lt;BR /&gt;[{"Name":"Henry","Sex":"M","Age":14,"Height":63.5,"Weight":102.5}]&lt;BR /&gt;[{"Name":"James","Sex":"M","Age":12,"Height":57.3,"Weight":83}]&lt;BR /&gt;[{"Name":"Jane","Sex":"F","Age":12,"Height":59.8,"Weight":84.5}]&lt;BR /&gt;[{"Name":"Janet","Sex":"F","Age":15,"Height":62.5,"Weight":112.5}]&lt;BR /&gt;[{"Name":"Jeffrey","Sex":"M","Age":13,"Height":62.5,"Weight":84}]&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 22:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512763#M73110</guid>
      <dc:creator>sundeep23</dc:creator>
      <dc:date>2018-11-13T22:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512923#M73112</link>
      <description>&lt;P&gt;Simple enough to strip out the "[" and "]" in each line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 set sashelp.class;
 call execute(catt('filename out "c:\temp\out',_n_,'.json";'));
 call execute('proc json out=out nosastags ;');
 call execute('export sashelp.class(obs='||_n_||' firstobs='||_n_||');');
 call execute('run;');
run;

data _null_;
 file "c:\temp\final.json" ;
 infile "c:\temp\out*.json";
 input;
 final = substr(_infile_,2,length(_infile_)-2);
 put final;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Nov 2018 12:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512923#M73112</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-11-14T12:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512999#M73118</link>
      <description>&lt;P&gt;Your question here inspired a blog post with what we've learned so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2018/11/14/jsonl-with-proc-json/" target="_self"&gt;Create newline-delimited JSON (or JSONL) in SAS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a bonus, I also included a tip for how to gzip-compress the output file at the same time, which I've read is a common need.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 16:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/512999#M73118</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-11-14T16:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/513122#M73134</link>
      <description>&lt;P&gt;Thats great thanks Chris for the blog.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 22:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/513122#M73134</guid>
      <dc:creator>sundeep23</dc:creator>
      <dc:date>2018-11-14T22:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/513531#M73146</link>
      <description>&lt;P&gt;Chris' solution is interesting, but I think it's a bit easier to have PROC JSON create the whole thing, then strip out the crud around it and insert newlines automatically, so long as the total string length is 32767 or less per line (adjust the length str $1024 to the appropriate length).&amp;nbsp; If it's over that, you will have issues in either solution and may be better off generating a single file from SAS and then using&amp;nbsp;another program (python, for example) to write a simple script to remove the [{ }] and commas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: I'm making some hopefully minor changes to deal with files &amp;gt; 32767 in length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out "c:\class.json" encoding="utf-8" termstr=cr;    *wherever you put this;
filename jsonbuf temp;           *temporary location for initial json output;
proc json out=jsonbuf nosastags; *output the whole datafile;
  export sashelp.class;
run;

data _null_;
  infile jsonbuf dsd dlmstr='},{' eof=_end;  *each record is delimited by this;
  file out;
  length str $1024;                          *make sure this is long enough for your records;
  
  do _n_ = 1 by 1;                           *just iterating, eof will exit the loop when done;
  	input str  $ @;                      *read that record in;
  	if str  =: '[{' then str   = substr(str  ,3);   *first record, cut off the starting bit;
  	if reverse(trim(str )) =: ']}' then str  = substr(str  ,1,length(str)-2);  *last record, cut off the ending bit;
  	str  = cats('{',str,'}');            *put back in the { } outside braces we lost using DLMSTR;
  	putlog str;                          *just for debugging;
  	put str $;                           *write it out to final file;
  end;
 
_end:                                        *where we go when end of file is reached;
  stop;
  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 19:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/513531#M73146</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2018-11-15T19:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/513557#M73150</link>
      <description>&lt;P&gt;Easier to post this separately I think.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to test speed, and so generated a moderate sized JSON (1.9 million lines).&amp;nbsp; This fails with my earlier program as it's over 32767 total line size for the one-line JSON export, so I modify it to use RECFM=N, otherwise it's largely the same.&amp;nbsp; The EOF=_END bit is no longer really needed as EOF isn't reached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out "h:\class.json"  encoding="utf-8" termstr=cr;
filename jsonbuf temp;
data class;
  set sashelp.class;
  do _n_ = 1 to 1e5;
    output;
  end;
run;


proc json out=jsonbuf nosastags;
  export class;
run;

data _null_;
  infile jsonbuf dsd dlmstr='},{' eof=_end recfm=n;
  file out;
  length str $1024;
  
  do _n_ = 1 by 1 until (str=' ');
  	input str  $ @;
  	if str  =: '[{' then str   = substr(str  ,3);
  	if reverse(trim(str )) =: ']}' then str  = substr(str  ,1,length(str)-2);
  	str  = cats('{',str,'}');
  	*putlog str;
  	put str $;
  end;
 
_end:
  stop;
  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 19:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/513557#M73150</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2018-11-15T19:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/514461#M73208</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/46466"&gt;@snoopy369&lt;/a&gt;&amp;nbsp;- thanks for the optimized approach! Your method is definitely&amp;nbsp;&lt;STRONG&gt;much&lt;/STRONG&gt; faster for the straight one-record-per-line JSON. Writing a single file with PROC JSON is much faster than writing a thousand (or more), and then post-processing each of those to combine them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But JSONL can have nested data (I guess that's why its enthusiasts like it over CSV), and the use of "},{" as a line delimiter for parsing doesn't work in that case -- and I think there might still be a need to write this style of JSON (with PROC JSON) as one-file-per-complete record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've never had a business case for JSONL, so I can only speculate what the data needs might be.&amp;nbsp; But consider this example (adapted from SAS doc):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename jsonbuf "C:\temp\MultipleDataSets.json";
proc json out=jsonbuf nokeys nosastags;
   write value "data";
   write open object; /* top-level object */
     write value "Roster";
       write open array; /* class list array */
         export sashelp.class ( drop=height weight) /keys;
       write close; /* class list array */
     write value "Measures";
     write open array; /* results array */
       export sashelp.classfit ( drop=name)/ keys;
     write close; /* results array */
   write close; /* top-level object */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output here defies the simple line parsing, as the associated data values are spread out (structurally) in the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To put the nested set of values together in a single JSON record, one per set of values, you might need something like this.&amp;nbsp; It's more complex than my CALL EXECUTE approach, as more data prep is needed to write out small data sets with source data.&amp;nbsp; And the resulting JSON is a little different, so the post-process doesn't need to trim the "[ ]".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* build the macro list of ID keys */
proc sql;
 select name into: id1- from sashelp.class;
 %let recordcount = &amp;amp;sqlobs;
quit;

/* Create a new subfolder in WORK to hold */
/* temp JSON files, avoiding conflicts    */
options dlcreatedir;
%let workpath = %sysfunc(getoption(WORK))/json;
libname json "&amp;amp;workpath.";
libname json clear;


%macro buildJson;

 %do i = 1 %to &amp;amp;recordcount.;

  data class;
   set sashelp.class (where=(name="&amp;amp;&amp;amp;id&amp;amp;i."));
  run;
  data classfit;
   set sashelp.classfit (where=(name="&amp;amp;&amp;amp;id&amp;amp;i."));
  run;

  filename jsonbuf "&amp;amp;workpath./out&amp;amp;i..json";
  proc json out=jsonbuf nokeys nosastags;
     write open object; /* top-level object */
       write value "Roster";
         write open array; /* class list array */
           export class (  drop=height weight) /keys;
         write close; /* class list array */
       write value "Measures";
       write open array; /* results array */
         export classfit ( drop=name) / keys;
       write close; /* results array */
     write close; /* top-level object */
  run;
 %end;
%mend;
%buildJson;

filename final "c:\temp\final.jsonl";
/* This will concatenate the collection of JSON files */
/* into a single JSONL file                           */
data _null_;
 file final encoding='utf-8' termstr=cr;
 infile "&amp;amp;workpath./out*.json";
 input;
 final = _infile_;
 put final;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 14:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/514461#M73208</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-11-19T14:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/514895#M73220</link>
      <description>Nicely Annotated!</description>
      <pubDate>Tue, 20 Nov 2018 18:59:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/514895#M73220</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-11-20T18:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Json</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/821560#M81913</link>
      <description>&lt;P&gt;How to read&amp;nbsp;&lt;SPAN&gt;JSONL&amp;nbsp;in SAS&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 09:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Json-to-create-newline-delimited-JSON-JSONL/m-p/821560#M81913</guid>
      <dc:creator>NovGetRight</dc:creator>
      <dc:date>2022-07-05T09:45:40Z</dc:date>
    </item>
  </channel>
</rss>

