<?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- Quoted items in an array in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869448#M82634</link>
    <description>&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your repost of the $quote. thing was what did it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I manipulated my programtype array data to look like this as a string:&lt;/P&gt;
&lt;P&gt;["11", "10", "9", "16", "14", "1"]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then I wrote it out as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"programname":' programname :$quote. /',&lt;BR /&gt;"programtype":' programtype /',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;without the outside quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That gives me the output I want&lt;/P&gt;
&lt;P&gt;, "programname":"name"&lt;BR /&gt;, "programtype":["1", "16"]&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;except that (unlike you, and I know this will probably tick you off - LOL) I HATE with a passion the commas at the beginning of the line&amp;nbsp; and would really prefer&lt;/P&gt;
&lt;P&gt;"programname":"name",&lt;BR /&gt;"programtype":["1", "16"],&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know the arguments, I just like them at the end. I don't know how to move them so i guess I am stuck until I figure that out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for tweaking my brain.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Apr 2023 17:54:16 GMT</pubDate>
    <dc:creator>HB</dc:creator>
    <dc:date>2023-04-12T17:54:16Z</dc:date>
    <item>
      <title>Proc JSON- Quoted items in an array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869438#M82632</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to generate JSON that looks like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;"key1": "value1",&lt;BR /&gt;"key2": ["arrayvalue1", "arrayvalue2", "arrayvalue3"],&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above format works and displays when I feed it to a Web page.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc json out = "mylocation\filename.json" pretty nosastags;&lt;BR /&gt;export myoutputtable;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This runs/works (and could be a cool time saver), but delivers JSON looking like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;"key1": "value1",&lt;BR /&gt;"key2": "[\"arrayvalue1\", \"arrayvalue2\", \"arrayvalue3\"]",&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it quotes the whole array and escapes the quotes on the items inside.&amp;nbsp; Blows things up.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anybody tell me how or even if I can tweak Proc JSON to adjust the output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I can't, I sort of get this solution from Tom&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813357" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Export-Nested-JSON/m-p/813357&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;but don't readily see how to adapt that writing a value array with variable item counts.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 16:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869438#M82632</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2023-04-12T16:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc JSON- Quoted items in an array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869444#M82633</link>
      <description>&lt;P&gt;Instead of using code like this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  /' ,"URL":{"path":' url :$quote. '}'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to create a JSON object you could use code like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/' ,"key2": [' stringvar ']'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to create a JSON array.&amp;nbsp; Where KEY2 is the name for the array and STRINGVAR is the single variable with a value like:&lt;/P&gt;
&lt;PRE&gt;"arrayvalue1", "arrayvalue2", "arrayvalue3"&lt;/PRE&gt;
&lt;P&gt;Or use a DO loop to write multiple individual values.&amp;nbsp; Either by looping over an array (SAS data step array) of the values, only writing the non-missing values.&amp;nbsp; Or using BY group processing to write values from multiple observations of the same variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS Again, write the continuation characters at beginning of the lines where they are easier for humans to scan.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 17:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869444#M82633</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-12T17:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc JSON- Quoted items in an array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869448#M82634</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your repost of the $quote. thing was what did it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I manipulated my programtype array data to look like this as a string:&lt;/P&gt;
&lt;P&gt;["11", "10", "9", "16", "14", "1"]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then I wrote it out as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"programname":' programname :$quote. /',&lt;BR /&gt;"programtype":' programtype /',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;without the outside quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That gives me the output I want&lt;/P&gt;
&lt;P&gt;, "programname":"name"&lt;BR /&gt;, "programtype":["1", "16"]&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;except that (unlike you, and I know this will probably tick you off - LOL) I HATE with a passion the commas at the beginning of the line&amp;nbsp; and would really prefer&lt;/P&gt;
&lt;P&gt;"programname":"name",&lt;BR /&gt;"programtype":["1", "16"],&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know the arguments, I just like them at the end. I don't know how to move them so i guess I am stuck until I figure that out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for tweaking my brain.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 17:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869448#M82634</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2023-04-12T17:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc JSON- Quoted items in an array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869472#M82635</link>
      <description>&lt;P&gt;Yep.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;item&lt;/P&gt;
&lt;P&gt;,item&lt;/P&gt;
&lt;P&gt;,item&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;doesn't work. Never loads.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I do need&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;item,&lt;/P&gt;
&lt;P&gt;item,&lt;/P&gt;
&lt;P&gt;item&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for the code to like and display it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried every rearrangement of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;"key":' dataset_value :$quote. /',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can think of with no joy.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"key":' dataset_value :$quote.&amp;nbsp; ,/'&lt;BR /&gt;&amp;nbsp;"key":' dataset_value :$quote. ' ,/&lt;/P&gt;
&lt;P&gt;"key":' dataset_value :$quote. ' , /n&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I do it?&amp;nbsp; Looking at you Tom.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 20:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-JSON-Quoted-items-in-an-array/m-p/869472#M82635</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2023-04-12T20:41:02Z</dc:date>
    </item>
  </channel>
</rss>

