<?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: Concatenating JSON objects in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/871767#M344431</link>
    <description>&lt;P&gt;So, how should I modify the code?&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2023 03:11:32 GMT</pubDate>
    <dc:creator>bayzid</dc:creator>
    <dc:date>2023-04-25T03:11:32Z</dc:date>
    <item>
      <title>Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870636#M343871</link>
      <description>&lt;P&gt;I am trying to concatenate multiple JSON files and then converting the resulting file into SAS format. How can I include the source filename as a new variable in the concatenated file?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 20:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870636#M343871</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T20:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870642#M343874</link>
      <description>&lt;P&gt;Can you show sample code you are using to read and concatenate two JSON files?&amp;nbsp; And perhaps attach two small sample JSON files (or include code to generate the two sample JSON files).&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 20:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870642#M343874</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-19T20:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870644#M343876</link>
      <description>&lt;P&gt;data _null_;&lt;BR /&gt;/* Iterate over all the files input */&lt;BR /&gt;infile '\json_test\MyDrug*.json' end=eof;&lt;BR /&gt;/* Open the file to write the output to */&lt;BR /&gt;file '\MyDrug_all.json';&lt;BR /&gt;&lt;BR /&gt;/* Read a line of input */&lt;BR /&gt;input;&lt;BR /&gt;&lt;BR /&gt;/* If this is the first line in the file print it to the output file verbatim */&lt;BR /&gt;if _n_ = 1 then&lt;BR /&gt;put _infile_;&lt;BR /&gt;/* If this is the last line print it out verbatim */&lt;BR /&gt;else if eof then&lt;BR /&gt;put _infile_;&lt;BR /&gt;/* Otherwise we are in the middle somewhere */&lt;BR /&gt;else do&lt;BR /&gt;/* Check what the first character of the line is */&lt;BR /&gt;/* Its either [, ], or , */&lt;BR /&gt;first_character = substr(_infile_,1,1);&lt;BR /&gt;select (first_character);&lt;BR /&gt;/* If its [ we must remove it */&lt;BR /&gt;when ("[") do;&lt;BR /&gt;line_without_first_character = substr(_infile_,2);&lt;BR /&gt;put line_without_first_character;&lt;BR /&gt;end;&lt;BR /&gt;/* If its ] we must swap it to a , to allow more objects in the array */&lt;BR /&gt;when ("]") put "," @@;&lt;BR /&gt;otherwise put _infile_;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 20:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870644#M343876</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T20:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870645#M343877</link>
      <description />
      <pubDate>Wed, 19 Apr 2023 20:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870645#M343877</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T20:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870646#M343878</link>
      <description>&lt;P&gt;I have no idea how you would do that in JSON objects. However if your read the JSON into separate data sets SAS can add the source data set name very easily. If you want the JSON file name that would mean you want to do something when creating the SAS data set from JSON to include the file, which may depend on how you are reading it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have two (or more) SAS data sets the example code would look like:&lt;/P&gt;
&lt;PRE&gt;data want;
    set data1 data2 indsname=fname;
    source = fname;
run;&lt;/PRE&gt;
&lt;P&gt;The INDSNAME= option assigns the name of the data set contributing the observation to a temporary variable named after the =, in this case Fname. Temporary means that it is not written to the data set. To have the value kept you assign it to another variable that will be in the output.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 20:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870646#M343878</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-19T20:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870647#M343879</link>
      <description>&lt;P&gt;Looks like you're manually reading the json files and writing a new json file, right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a filename=&amp;nbsp; option file the INFILE statement which will create a temporary variable that has the name of the current input file.&amp;nbsp; So it might be possible to&amp;nbsp; use that to add a field to your output json file with the name of the file each record came from.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But seems like this would be easier to start by reading in each JSON file (with JSON engine), and then concatenate them in SAS.&amp;nbsp; Or perhaps make a single filreref which points to all the JSON files, and read that using the JSON engine.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 21:00:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870647#M343879</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-19T21:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870648#M343880</link>
      <description>&lt;P&gt;Hi ballardw,&lt;/P&gt;&lt;P&gt;I know that it is very easy to add source file name while concatenating multiple SAS files. But for my situation, i need to concatenate the JSON files before converting to SAS file.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 21:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870648#M343880</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T21:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870650#M343881</link>
      <description>&lt;P&gt;Hi Quentin,&lt;/P&gt;&lt;P&gt;Can you please show me an example code?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 21:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870650#M343881</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T21:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870651#M343882</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/108705"&gt;@bayzid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi ballardw,&lt;/P&gt;
&lt;P&gt;I know that it is very easy to add source file name while concatenating multiple SAS files. But for my situation, &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;i need to concatenate the JSON files before converting to SAS file.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think this is where we disagree with you. You should read each file separately and append the results into one SAS file with the dates. Can you clarify why you think you need to combine them first?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 21:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870651#M343882</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-04-19T21:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870652#M343883</link>
      <description>&lt;P&gt;Hi Reeza,&lt;BR /&gt;For most of the variables, the length and variable type varies across datasets. SAS cannot handle this during concatenation.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 21:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870652#M343883</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T21:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870653#M343884</link>
      <description>&lt;P&gt;I would use a macro to read one file at a time and capture the name of the file, like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro readjson(file=/*json file*/,out=/*output sas dataset*/) ;

filename jfile "&amp;amp;file" ;
libname jfile json;

data &amp;amp;out ;
  set jfile.root ;
  length sourcefilename $200 ;
  retain sourcefilename "%scan(&amp;amp;file,-1,/\)" ;
run ;

filename jfile clear ;
libname jfile clear ;

%mend readjson ;

%readjson(file=C:\...\MyDrug_8c209d34-1b3c-48a5-ae3a-90763c4f4d2e.json,out=want1)
%readjson(file=C:\...\MyDrug_5b056720-1620-4e67-9f42-7a0587da9a08.json,out=want2)

data all ;
  set want1 want2 ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;One challenge with that approach is you end up with variable type conflicts (your column Schedule) and length conflicts.&amp;nbsp; So with this approach, I use a data dictionary to impose types/lengths after reading the data. Or, probably better, you could specify a json map when you read the data.&amp;nbsp; I suppose putting all of the data into one json file would avoid this problem, but it still feels messy.&amp;nbsp; If you're going to need to do this a lot, I think I would put in the time to define a map for the json file, and then use that to read each file into a SAS dataset, and then combine them.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 21:25:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870653#M343884</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-19T21:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870654#M343885</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;Thanks for the code. Unfortunately, it didn't work. Data want2 was not created and data want1 was empty.&lt;BR /&gt;I am trying to concatenate all the JSON file before conversation to SAS due to the reason you have mentioned.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 21:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870654#M343885</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T21:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870655#M343886</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/108705"&gt;@bayzid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza,&lt;BR /&gt;For most of the variables, the length and variable type varies across datasets. &lt;STRONG&gt;SAS cannot handle this during concatenation.&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That should have been your question. Fix your folder path accordingly and this will read all the files and combine them into one. Then use PROC TRANSPOSE to flip if you want the wide format.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dirtree url 
    'https://raw.githubusercontent.com/sasutils/macros/master/dirtree.sas';
%include dirtree /source2;
%dirtree(/home/fkhurshed/CLASS1    /* Pipe delimited directory list (default=.) */
        , out=filelist  /* Output dataset name */
        , maxdepth=1 /* Maximum tree depth */);

%macro read_json(myfile=);
    filename mydata &amp;amp;myfile.;
    libname myjson JSON fileref=mydata;

    proc datasets lib=myjson;
    quit;

    *how to parse the file has not been specified - looks like you need to specify the lengths;

    data file2save;
        length source $200. p1 $256. Value $256.;
        set myjson.alldata;
        source=&amp;amp;myfile.;
    run;

    proc append base=master data=file2save force;
    run;

    proc sql;
        drop table file2save;
    quit;

    filename mydata;
    libname myjson;
%mend read_json;

proc sql;
    drop table master;
quit;

data run_list;
    set filelist;
    where type='F';
    str=catt('%read_json(myfile="/home/fkhurshed/CLASS1/', filename, '");');
    call execute(str);
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>Wed, 19 Apr 2023 21:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870655#M343886</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-04-19T21:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870658#M343888</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/108705"&gt;@bayzid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza,&lt;BR /&gt;For most of the variables, the length and variable type varies across datasets. SAS cannot handle this during concatenation.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you read the JSON files use the SAME mapping each time and the variables will be defined consistently.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 22:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870658#M343888</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-19T22:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870659#M343889</link>
      <description>&lt;P&gt;Hi Reeza,&lt;BR /&gt;Thanks for the code. It ran with lots of errors. The Master dataset was empty. The log file is attached.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 22:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870659#M343889</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T22:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870662#M343891</link>
      <description>&lt;P&gt;Your JSON is sooooooo simple you could just read it as name/value pairs directly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall ;
  length row col 8 name $32 value $256 ;
  length filen filename $256 ;
  infile "c:\downloads\MyDrug*.json" dlm='[{,:}]' truncover length=ll column=cc filename=filen;
  input @;
  if filen ne lag(filen) then row=0;
  filename=filen;
  row+1;
  do col=1 by 1 until(cc&amp;gt;ll);
    input name value @ ;
    name=dequote(name);
    if value='null' then value=' ';
    else value=dequote(value);
    if name ne ' ' then output;
  end;
run;

proc transpose data=tall out=wide(drop=_name_);
  by filename row ;
  id name;
  var value;
run;

proc print data=wide ;
 where row=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1681942571760.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82851i74A7732B0B4F3CCA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1681942571760.png" alt="Tom_0-1681942571760.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 22:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870662#M343891</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-19T22:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870668#M343894</link>
      <description>&lt;P&gt;Hi Tom,&lt;BR /&gt;That's excellent. I am almost there. With my complete data pool (&amp;gt;83k JSON files into 21 groups) the tall is being created without any issue but the transpose proc is not working. It's returning the following error message.&lt;BR /&gt;NOTE: The above message was for the following BY group:&lt;BR /&gt;filename=C:\...ts\JSON_1st_0203&lt;BR /&gt;ERROR: The ID value "null" occurs twice in the same BY group.&lt;BR /&gt;ERROR: The ID value "false" occurs twice in the same BY group.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 22:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870668#M343894</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-19T22:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870672#M343898</link>
      <description>This is your issue from the log. &lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/JSON-File-is-locked-error/td-p/851162" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/JSON-File-is-locked-error/td-p/851162&lt;/A&gt;</description>
      <pubDate>Wed, 19 Apr 2023 22:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870672#M343898</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-04-19T22:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870680#M343904</link>
      <description>&lt;P&gt;Hi Tom,&lt;BR /&gt;I found the reason for the error message. You are using comma as a delimiter but it also appears in some of the values. Then the problem happens.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bayzid_0-1681949526977.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82855iB63F6A733870A3AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bayzid_0-1681949526977.png" alt="bayzid_0-1681949526977.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bayzid_1-1681949603832.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82856iB4C84D69057397BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bayzid_1-1681949603832.png" alt="bayzid_1-1681949603832.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there a way to get around this problem easily?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 00:13:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870680#M343904</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-20T00:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating JSON objects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870681#M343905</link>
      <description>&lt;P&gt;You could try adding the DSD option, that will allow the quotes to protect the delimiters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall ;
  length row col 8 name $32 value $256 ;
  length filen filename $256 ;
  infile "c:\downloads\MyDrug*.json" dlm='[{,:}]' dsd truncover length=ll column=cc filename=filen;
  input @;
  if filen ne lag(filen) then row=0;
  filename=filen;
  row+1;
  do col=1 by 1 until(cc&amp;gt;ll);
    input name value @;
    name=dequote(name);
    if value='null' then value=' ';
    else value=dequote(value);
    if name ne ' ' then output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The [{ or ,{ at the start of each line will cause there to be two extra empty values, but the IF statement that ignores the pairs without a name will cause those to be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 12:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-JSON-objects/m-p/870681#M343905</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-20T12:03:14Z</dc:date>
    </item>
  </channel>
</rss>

