<?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 Export Nested JSON in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813358#M81806</link>
    <description>&lt;P&gt;Why not just write it yourself?&amp;nbsp; JSON files are just text.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "path\name.json" ;
  set have end=eof;
  if _n_=1 then put '[' / ' {' @;
  else put ',{' @;
  put 
    '"category_id":' category_id
  /' ,"name":' name :$quote.
  /' ,"description":' description :$quote.
  /' ,"page_title":' page_title :$quote.
  /' ,"meta_description":' meta_description :$quote.
  /' ,"URL":{"path":' url :$quote. '}'
  /' }'
  ;
  if eof then put ']';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;[
 {"category_id":123
 ,"name":"name_example"
 ,"description":"description_example"
 ,"page_title":"page_example"
 ,"meta_description":"meta_example"
 ,"URL":{"path":"url_example" }
 }
]&lt;/PRE&gt;
&lt;P&gt;PS Why place continuation characters at the end of the lines where they are hard for humans to scan?&lt;/P&gt;</description>
    <pubDate>Sat, 14 May 2022 20:49:06 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-05-14T20:49:06Z</dc:date>
    <item>
      <title>Proc JSON Export Nested JSON</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813357#M81805</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I am using Proc JSON to output a SAS dataset into JSON format. The first block of JSON below is the default output and the second block is what I am trying to do.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Basic Proc JSON code:&lt;BR /&gt;proc json out="path\name.json" pretty nosastags;&lt;BR /&gt;export dataset;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Default JSON output:
[
  {
    "category_id": 123,
    "name": "name_example",
    "description": "description_example",
    "page_title": "page_example",
    "meta_description": "meta_example",
    "URL": "url_example"
  }
]
What I need:
[
  {
    "category_id": 123,
    "name": "name_example",
    "description": "description_example",
    "page_title": "page_example",
    "meta_description": "meta_example",
    &lt;U&gt;&lt;FONT color="#FF0000"&gt;"URL": {
	"path": "url_example"&lt;/FONT&gt;&lt;/U&gt;
	}
  }
]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have tried various statements within Proc JSON (write values, arrays, objects, etc.) but that doesn't seem to get me what I need. What do I need to do to achieve the output I shared above?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 20:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813357#M81805</guid>
      <dc:creator>CR-Horton</dc:creator>
      <dc:date>2022-05-14T20:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc JSON Export Nested JSON</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813358#M81806</link>
      <description>&lt;P&gt;Why not just write it yourself?&amp;nbsp; JSON files are just text.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "path\name.json" ;
  set have end=eof;
  if _n_=1 then put '[' / ' {' @;
  else put ',{' @;
  put 
    '"category_id":' category_id
  /' ,"name":' name :$quote.
  /' ,"description":' description :$quote.
  /' ,"page_title":' page_title :$quote.
  /' ,"meta_description":' meta_description :$quote.
  /' ,"URL":{"path":' url :$quote. '}'
  /' }'
  ;
  if eof then put ']';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;[
 {"category_id":123
 ,"name":"name_example"
 ,"description":"description_example"
 ,"page_title":"page_example"
 ,"meta_description":"meta_example"
 ,"URL":{"path":"url_example" }
 }
]&lt;/PRE&gt;
&lt;P&gt;PS Why place continuation characters at the end of the lines where they are hard for humans to scan?&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 20:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813358#M81806</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-14T20:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc JSON Export Nested JSON</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813383#M81807</link>
      <description>Awesome! Thanks a lot, Tom. Appreciate the quick help.</description>
      <pubDate>Sun, 15 May 2022 18:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813383#M81807</guid>
      <dc:creator>CR-Horton</dc:creator>
      <dc:date>2022-05-15T18:24:04Z</dc:date>
    </item>
  </channel>
</rss>

