<?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: How to wirte ALLDATA data set back to JSON in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754512#M237950</link>
    <description>&lt;P&gt;Have you tried proc json?&lt;/P&gt;</description>
    <pubDate>Fri, 16 Jul 2021 08:23:29 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-07-16T08:23:29Z</dc:date>
    <item>
      <title>How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754506#M237947</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using the JSON engine to read a JSON file, an ALLDATA data set was created. How can I convert the ALLDATA data set back to JSON?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 07:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754506#M237947</guid>
      <dc:creator>ST9</dc:creator>
      <dc:date>2021-07-16T07:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754512#M237950</link>
      <description>&lt;P&gt;Have you tried proc json?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 08:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754512#M237950</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-16T08:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754515#M237952</link>
      <description>&lt;P&gt;Yes, I tried proc json with nosastags, nokeys, and pretty option. The sturcture/layout of the output file is completely different than the original JSON.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 08:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754515#M237952</guid>
      <dc:creator>ST9</dc:creator>
      <dc:date>2021-07-16T08:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754520#M237955</link>
      <description>&lt;P&gt;So is question is: how to export to JSON using a specific structure. Not how to export JSON.&lt;/P&gt;
&lt;P&gt;Show us what you tried, and what the desired format looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 08:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754520#M237955</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-16T08:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754527#M237961</link>
      <description>&lt;P&gt;Sorry for the confusion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The JSON I'd like to process:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "group": {
    "prod": {
      "info": {
        "id": 13579,
        "sub": {
          "02468": {
            "description": "Description 1",
            "config": {
              "os": "windows"
            },
            "build": {
              "ver": "1133557799"
            },
            "checksums": {
              "hex": {
                "md5": "a8a64cef262a04de4872b68b63ab7cd8",
                "sha1": "d80a9e5ac1c9f4343d30f70f9f6c2be247cee375"
              }
            }
          }
        },
        "storage": {
          "quota": 22446688,
          "count": 999
        }
      }
    },
    "test": {
      "info": {
        "id": 13579,
        "sub": {
          "02468": {
            "description": "Description 2",
            "config": {
              "os": "unix"
            },
            "build": {
              "ver": "1133557799"
            },
            "checksums": {
              "hex": {
                "md5": "a8a64cef262a04de4872b68b63ab7cd8",
                "sha1": "d80a9e5ac1c9f4343d30f70f9f6c2be247cee375"
              }
            }
          }
        },
        "storage": {
          "quota": 22446688,
          "count": 999
        }
      }
    }
  }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is what've tried so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dir = %str(C:\Users\XXXXX\Desktop\Temp);

filename input "&amp;amp;dir\input.json";
libname input json;

data output;
    set input.alldata;
run;

proc json out="&amp;amp;dir\output.json" nosastags nokeys pretty;
   export output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By running the code above, I got:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[
  [
    1,
    "group",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    2,
    "group",
    "prod",
    "",
    "",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    3,
    "group",
    "prod",
    "info",
    "",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    4,
    "group",
    "prod",
    "info",
    "id",
    "",
    "",
    "",
    "",
    1,
    "13579"
  ],
  [
    4,
    "group",
    "prod",
    "info",
    "sub",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    5,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    6,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "description",
    "",
    "",
    1,
    "Description 1"
  ],
  [
    6,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "config",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "config",
    "os",
    "",
    1,
    "windows"
  ],
  [
    6,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "build",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "build",
    "ver",
    "",
    1,
    "1133557799"
  ],
  [
    6,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "checksums",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "",
    0,
    ""
  ],
  [
    8,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "md5",
    1,
    "a8a64cef262a04de4872b68b63ab7cd8"
  ],
  [
    8,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "sha1",
    1,
    "d80a9e5ac1c9f4343d30f70f9f6c2be247cee375"
  ],
  [
    4,
    "group",
    "prod",
    "info",
    "storage",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    5,
    "group",
    "prod",
    "info",
    "storage",
    "quota",
    "",
    "",
    "",
    1,
    "22446688"
  ],
  [
    5,
    "group",
    "prod",
    "info",
    "storage",
    "count",
    "",
    "",
    "",
    1,
    "999"
  ],
  [
    2,
    "group",
    "test",
    "",
    "",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    3,
    "group",
    "test",
    "info",
    "",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    4,
    "group",
    "test",
    "info",
    "id",
    "",
    "",
    "",
    "",
    1,
    "13579"
  ],
  [
    4,
    "group",
    "test",
    "info",
    "sub",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    5,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    6,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "description",
    "",
    "",
    1,
    "Description 2"
  ],
  [
    6,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "config",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "config",
    "os",
    "",
    1,
    "unix"
  ],
  [
    6,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "build",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "build",
    "ver",
    "",
    1,
    "1133557799"
  ],
  [
    6,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "checksums",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "",
    0,
    ""
  ],
  [
    8,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "md5",
    1,
    "a8a64cef262a04de4872b68b63ab7cd8"
  ],
  [
    8,
    "group",
    "test",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "sha1",
    1,
    "d80a9e5ac1c9f4343d30f70f9f6c2be247cee375"
  ],
  [
    4,
    "group",
    "test",
    "info",
    "storage",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    5,
    "group",
    "test",
    "info",
    "storage",
    "quota",
    "",
    "",
    "",
    1,
    "22446688"
  ],
  [
    5,
    "group",
    "test",
    "info",
    "storage",
    "count",
    "",
    "",
    "",
    1,
    "999"
  ]
]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I'd like the output file to have the same structure as the original input file, which is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "group": {
    "prod": {
      "info": {
        "id": 13579,
        "sub": {
          "02468": {
            "description": "Description 1",
            "config": {
              "os": "windows"
            },
            "build": {
              "ver": "1133557799"
            },
            "checksums": {
              "hex": {
                "md5": "a8a64cef262a04de4872b68b63ab7cd8",
                "sha1": "d80a9e5ac1c9f4343d30f70f9f6c2be247cee375"
              }
            }
          }
        },
        "storage": {
          "quota": 22446688,
          "count": 999
        }
      }
    },
    "test": {
      "info": {
        "id": 13579,
        "sub": {
          "02468": {
            "description": "Description 2",
            "config": {
              "os": "unix"
            },
            "build": {
              "ver": "1133557799"
            },
            "checksums": {
              "hex": {
                "md5": "a8a64cef262a04de4872b68b63ab7cd8",
                "sha1": "d80a9e5ac1c9f4343d30f70f9f6c2be247cee375"
              }
            }
          }
        },
        "storage": {
          "quota": 22446688,
          "count": 999
        }
      }
    }
  }
}&lt;/PRE&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 09:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754527#M237961</guid>
      <dc:creator>ST9</dc:creator>
      <dc:date>2021-07-16T09:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754574#M237983</link>
      <description>Data step is most powerful tool to write json .</description>
      <pubDate>Fri, 16 Jul 2021 12:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754574#M237983</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-07-16T12:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754704#M238061</link>
      <description>&lt;P&gt;Thank you, and sorry for not describing the question clearly. Below is the JSON file I'd like to process:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "group": {
    "prod": {
      "info": {
        "id": 13579,
        "sub": {
          "02468": {
            "description": "Description 1",
            "config": {
              "os": "windows"
            },
            "build": {
              "ver": "1133557799"
            },
            "checksums": {
              "hex": {
                "md5": "a8a64cef262a04de4872b68b63ab7cd8",
                "sha1": "d80a9e5ac1c9f4343d30f70f9f6c2be247cee375"
              }
            }
          }
        },
        "storage": {
          "quota": 22446688,
          "count": 999
        }
      }
    }
  }
}&lt;/PRE&gt;&lt;P&gt;I would like to have the output file to have the same sturcture as the input file above. I've tried the following code:&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;%let dir = %str(C:\Users\XXXXXX\Temp);

filename input "&amp;amp;dir\input.json";
libname input json;

data output;
    set input.alldata;
run;

proc json out="&amp;amp;dir\output.json" nosastags nokeys pretty;
   export output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the result I was getting is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[
  [
    1,
    "group",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    2,
    "group",
    "prod",
    "",
    "",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    3,
    "group",
    "prod",
    "info",
    "",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    4,
    "group",
    "prod",
    "info",
    "id",
    "",
    "",
    "",
    "",
    1,
    "13579"
  ],
  [
    4,
    "group",
    "prod",
    "info",
    "sub",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    5,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    6,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "description",
    "",
    "",
    1,
    "Description 1"
  ],
  [
    6,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "config",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "config",
    "os",
    "",
    1,
    "windows"
  ],
  [
    6,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "build",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "build",
    "ver",
    "",
    1,
    "1133557799"
  ],
  [
    6,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "checksums",
    "",
    "",
    0,
    ""
  ],
  [
    7,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "",
    0,
    ""
  ],
  [
    8,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "md5",
    1,
    "a8a64cef262a04de4872b68b63ab7cd8"
  ],
  [
    8,
    "group",
    "prod",
    "info",
    "sub",
    "02468",
    "checksums",
    "hex",
    "sha1",
    1,
    "d80a9e5ac1c9f4343d30f70f9f6c2be247cee375"
  ],
  [
    4,
    "group",
    "prod",
    "info",
    "storage",
    "",
    "",
    "",
    "",
    0,
    ""
  ],
  [
    5,
    "group",
    "prod",
    "info",
    "storage",
    "quota",
    "",
    "",
    "",
    1,
    "22446688"
  ],
  [
    5,
    "group",
    "prod",
    "info",
    "storage",
    "count",
    "",
    "",
    "",
    1,
    "999"
  ]
]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 05:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754704#M238061</guid>
      <dc:creator>ST9</dc:creator>
      <dc:date>2021-07-17T05:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754713#M238066</link>
      <description>Your input file is highly hierarchical.
I have no idea how this is imported in SAS as a table (and can't test as my version is tool old to support JSON), but unless traces of the hierarchy are somehow kept in the non-hierarchical SAS table, there is no way to determine what the hierarchy should look like.
Maybe someone who has used the JSON engine in SAS can help, otherwise you might have to recreate the hierarchy programmatically.</description>
      <pubDate>Sat, 17 Jul 2021 07:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754713#M238066</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-17T07:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754717#M238068</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;Below how the alldata table looks like after import of the json via the libname json engine. The pictures shows all rows created (=the closing bit is not in the table).&lt;/P&gt;
&lt;P&gt;I'm with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;that a data step is best suited to recreate the source json structure from such a table.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1626509841261.png" style="width: 672px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61317i5479502CDD3F3AA8/image-dimensions/672x391?v=v2" width="672" height="391" role="button" title="Patrick_0-1626509841261.png" alt="Patrick_0-1626509841261.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 08:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754717#M238068</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-07-17T08:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754718#M238069</link>
      <description>&lt;P&gt;I was thinking that if SAS has offered an easy way to read and import a certain type of data, then there should also be an easy way to export the imported data to its original state. I've looked over the documentation but no luck, not sure if I missed something... Maybe I should try the data step instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks all!&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 08:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754718#M238069</guid>
      <dc:creator>ST9</dc:creator>
      <dc:date>2021-07-17T08:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754785#M238104</link>
      <description>&lt;P&gt;SAS use normal relational tables.&amp;nbsp; Not the nested stuff the JSON allows.&lt;/P&gt;
&lt;P&gt;You should look into seeing if you can just use a DATA step to convert the ALLDATA dataset into a JSON file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the change you are making to the data?&amp;nbsp; Perhaps you can just make the change in the JSON text itself?&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 17:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754785#M238104</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-17T17:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754990#M238199</link>
      <description>&lt;P&gt;You can programmatically create the desired output in JSON format using PROC JSON. It will be more involved than what you initially tried. I wrote a &lt;A href="https://communities.sas.com/t5/SAS-Programming/PROC-JSON-create-a-hierarchical-file/m-p/413679#M101279" target="_self"&gt;proof-of-concept program&lt;/A&gt; that shows how to create hierarchical JSON formatted output from a SAS data set. You should be able to use the concepts displayed in the program to produce the output you desire. One advantage of the JSON procedure is that it automatically produces syntactically correct JSON from the supplied data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 14:00:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/754990#M238199</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2021-07-19T14:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/758332#M239436</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to recreate the JSON with data steps. The code may not be concise enough, but at least it works...&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;%let dir=%str(C:\Users\XXXXX\Desktop\Temp);
filename input "&amp;amp;dir\input.json";
libname input json;

proc sql noprint;
    create table alldata as
        select *,
            case
                when Value='' then '' 
                when compress(Value, ,'kd')=Value then 'num'
                else 'char'
            end as ValueType,
            monotonic() as OID
        from input.alldata;

    select max(p) into :p_max
        from input.alldata;
quit;

* some code here to update/modify the ALLDATA dataset;

proc sort data=alldata out=temp;
    by desending OID;
run;

data temp;
    set temp;
    InsRow=P-lag(P);

    if InsRow le 0 then
        InsRow=.;

    if _n_=1 then
        InsRow=P;
run;

proc sort data=temp out=temp(drop=OID);
    by OID;
run;

%macro InsRow;

    data temp;
        set temp(obs=1) temp;

        if _n_=1 then
            call missing(of _all_);

        output;

        %do i=1 %to &amp;amp;p_max;
            if InsRow=&amp;amp;i then
                do;
                    call missing(of _all_);

                    %do j=1 %to &amp;amp;i;
                        output;
                    %end;
                end;
        %end;
    run;

%mend InsRow;

%InsRow;

data temp;
    set temp;

    if _n_=1 then
        Indent=0;
    else if P ne . then
        Indent=P;
    else Indent=Indent-1;
    retain Indent;

    OID=_n_;
run;

proc sort data=temp;
    by desending OID;
run;

data temp;
    set temp;
    Lead_Indent=lag(Indent);
run;

proc sort data=temp out=temp(drop=OID);
    by OID;
run;

%macro RebuildJSON;

    data temp;
        length JSON_output $640;
        set temp end=eof;

        Value=tranwrd(Value, '"', '\"');

        if _n_=1 then
            JSON_output=cat("$$", "{");
        else if eof then
            JSON_output=cat("$$", "}");

        %do i=1 %to &amp;amp;p_max;
        else if Indent=&amp;amp;i and V=0 then
            JSON_output=cat("$$", repeat("  ", &amp;amp;i-1), '"', strip(P&amp;amp;i), '"', ": {");
        else if Indent=&amp;amp;i and V=1 and ValueType="num" then
            JSON_output=cat("$$", repeat("  ", &amp;amp;i-1), '"', strip(P&amp;amp;i), '"', ": ", strip(Value));
        else if Indent=&amp;amp;i and V=1 and ValueType="char" then
            JSON_output=cat("$$", repeat("  ", &amp;amp;i-1), '"', strip(P&amp;amp;i), '"', ": ", '"', strip(Value), '"');
        else if Indent=&amp;amp;i and V=1 and ValueType="" then
            JSON_output=cat("$$", repeat("  ", &amp;amp;i-1), '"', strip(P&amp;amp;i), '"', ": ", '""');
        else if Indent=&amp;amp;i then
            JSON_output=cat("$$", repeat("  ", &amp;amp;i-1), "}");
        %end;

        if Indent=Lead_Indent then
            JSON_output=cat(strip(JSON_output), ",");
        else JSON_output=JSON_output;

        JSON_output=tranwrd(JSON_output, "{,", "{},");
    run;

%mend RebuildJSON;

%RebuildJSON;

data _null_;
    options nobomfile;
    file "&amp;amp;dir\output.json" encoding="utf-8";
    set temp(keep=JSON_output);
    JSON_output=tranwrd(JSON_output, "\", "\\");
    JSON_output=tranwrd(JSON_output, '\\"', '\"');
    put JSON_output $;
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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 06:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/758332#M239436</guid>
      <dc:creator>ST9</dc:creator>
      <dc:date>2021-07-30T06:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to wirte ALLDATA data set back to JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/758345#M239439</link>
      <description>&lt;P&gt;Well done!&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;P&gt;1. You can write&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;when compress(Value, ,'kd')=Value then 'num'&lt;/LI-CODE&gt;
&lt;P&gt;as&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;when compress(Value,'+-.','kd')=Value then 'num'&lt;/LI-CODE&gt;
&lt;P&gt;to capture decimals and negative numbers.&lt;/P&gt;
&lt;P&gt;2. You can write&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;  JSON_output=cat("$$", repeat("  ", &amp;amp;i-1), '"', strip(P&amp;amp;i), '"', ": {");&lt;/LI-CODE&gt;
&lt;P&gt;as&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;  JSON_output=cat("$$", repeat("  ", &amp;amp;i-1), quote(strip(P&amp;amp;i)), ": {");&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 07:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-wirte-ALLDATA-data-set-back-to-JSON/m-p/758345#M239439</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-30T07:56:19Z</dc:date>
    </item>
  </channel>
</rss>

