<?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 proc JSON export in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/509420#M1780</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try to output a JSON-File from three different tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;{
"ID":"1",
"Status":"2",
"Rechtsform_ID":"3",
  "Mitarbeiter": [
    {
      "WERT": "0",
      "QS": "X.99.9"
    },
    {
      "WERT": "1",
      "QS": "X.99.9"
    }
  ],
  "EFE": [
    {
      "FUNKTIONSART": "2",
      "PROXY": "0",
      "PERSKEYS": "AAA1BB2CCC",
      "GEBDAT": "1970-08-12",
      "EINTRITT": "2011-08-12"
    },
    {
      "FUNKTIONSART": "2",
      "PROXY": "0",
      "PERSKEYS": "xxxxxx",
      "GEBDAT": "1970-08-12",
      "EINTRITT": "2011-08-12"
    }
  ]
}
&lt;/PRE&gt;
&lt;P&gt;But I have a problem with the first part (table sub_main). How can I export this, without an&amp;nbsp; array (just key-value)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the program I have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sub_main;
ID="1";Status="2";Rechtsform_ID="3";output;
run;

data sub_ma;
WERT="0"; QS="X.99.9"; output;
WERT="11"; QS="X.99.9"; output;
run;

data sub_efe;
      FUNKTIONSART="2";
      PROXY="0";
      PERSKEYS="AAA1BB2CCC";
      GEBDAT="1970-08-12";
      EINTRITT="2011-08-12";
	  output;
	  FUNKTIONSART="2";
      PROXY="0";
      PERSKEYS="xxxxxx";
      GEBDAT="1970-08-12";
      EINTRITT="2011-08-12";
	  output;
run;
proc json out="D:\Output_HAVE.json" pretty  nosastags;
   write open object;
	/*   	write vaules "ID" "1";*/ /*&amp;lt;&amp;lt;&amp;lt;&amp;lt; works, bust its "hard coded*/

   /*		export sub_main*/ /*&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; dont work ;(*/

	   write values "Mitarbeiter";
	   	write open array;
	   	export sub_ma;
	   write close;
	 
	   write values "EFE";
	   	write open array;
	   	export sub_efe;
	   write close; 
   write close; 

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;And thats the result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;{
  "Mitarbeiter": [
    {
      "WERT": "0",
      "QS": "X.99.9"
    },
    {
      "WERT": "1",
      "QS": "X.99.9"
    }
  ],
  "EFE": [
    {
      "FUNKTIONSART": "2",
      "PROXY": "0",
      "PERSKEYS": "AAA1BB2CCC",
      "GEBDAT": "1970-08-12",
      "EINTRITT": "2011-08-12"
    },
    {
      "FUNKTIONSART": "2",
      "PROXY": "0",
      "PERSKEYS": "xxxxxx",
      "GEBDAT": "1970-08-12",
      "EINTRITT": "2011-08-12"
    }
  ]
}
&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Nov 2018 07:21:12 GMT</pubDate>
    <dc:creator>grimol</dc:creator>
    <dc:date>2018-11-01T07:21:12Z</dc:date>
    <item>
      <title>proc JSON export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/509420#M1780</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try to output a JSON-File from three different tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;{
"ID":"1",
"Status":"2",
"Rechtsform_ID":"3",
  "Mitarbeiter": [
    {
      "WERT": "0",
      "QS": "X.99.9"
    },
    {
      "WERT": "1",
      "QS": "X.99.9"
    }
  ],
  "EFE": [
    {
      "FUNKTIONSART": "2",
      "PROXY": "0",
      "PERSKEYS": "AAA1BB2CCC",
      "GEBDAT": "1970-08-12",
      "EINTRITT": "2011-08-12"
    },
    {
      "FUNKTIONSART": "2",
      "PROXY": "0",
      "PERSKEYS": "xxxxxx",
      "GEBDAT": "1970-08-12",
      "EINTRITT": "2011-08-12"
    }
  ]
}
&lt;/PRE&gt;
&lt;P&gt;But I have a problem with the first part (table sub_main). How can I export this, without an&amp;nbsp; array (just key-value)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the program I have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sub_main;
ID="1";Status="2";Rechtsform_ID="3";output;
run;

data sub_ma;
WERT="0"; QS="X.99.9"; output;
WERT="11"; QS="X.99.9"; output;
run;

data sub_efe;
      FUNKTIONSART="2";
      PROXY="0";
      PERSKEYS="AAA1BB2CCC";
      GEBDAT="1970-08-12";
      EINTRITT="2011-08-12";
	  output;
	  FUNKTIONSART="2";
      PROXY="0";
      PERSKEYS="xxxxxx";
      GEBDAT="1970-08-12";
      EINTRITT="2011-08-12";
	  output;
run;
proc json out="D:\Output_HAVE.json" pretty  nosastags;
   write open object;
	/*   	write vaules "ID" "1";*/ /*&amp;lt;&amp;lt;&amp;lt;&amp;lt; works, bust its "hard coded*/

   /*		export sub_main*/ /*&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; dont work ;(*/

	   write values "Mitarbeiter";
	   	write open array;
	   	export sub_ma;
	   write close;
	 
	   write values "EFE";
	   	write open array;
	   	export sub_efe;
	   write close; 
   write close; 

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;And thats the result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;{
  "Mitarbeiter": [
    {
      "WERT": "0",
      "QS": "X.99.9"
    },
    {
      "WERT": "1",
      "QS": "X.99.9"
    }
  ],
  "EFE": [
    {
      "FUNKTIONSART": "2",
      "PROXY": "0",
      "PERSKEYS": "AAA1BB2CCC",
      "GEBDAT": "1970-08-12",
      "EINTRITT": "2011-08-12"
    },
    {
      "FUNKTIONSART": "2",
      "PROXY": "0",
      "PERSKEYS": "xxxxxx",
      "GEBDAT": "1970-08-12",
      "EINTRITT": "2011-08-12"
    }
  ]
}
&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Nov 2018 07:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/509420#M1780</guid>
      <dc:creator>grimol</dc:creator>
      <dc:date>2018-11-01T07:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc JSON export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/509612#M1810</link>
      <description>&lt;P&gt;You will need to do a little extra processing to get the JSON output you desire. Instead of hardcoding the names and values from the 'sub_main' dataset, I used the SQL Dictionary tables to dynamically obtain the needed data. I then stored the data in macro variables and used those in the JSON procedure. This should give you an idea of a way to solve your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select name into :colName1 - :colName3 
from dictionary.columns
where libname = 'WORK' and memname = 'SUB_MAIN'
;
quit;
 %put &amp;amp;colName1, &amp;amp;colName2, &amp;amp;colName3;

proc sql;
select id, status, Rechtsform_ID into  :colValue1, :colValue2, :colValue3
from WORK.SUB_MAIN
;
quit;
%put &amp;amp;colValue1, &amp;amp;colValue2, &amp;amp;colValue3;

proc json out="output.json" pretty  nosastags;
   write open object;
     write values &amp;amp;colName1 &amp;amp;colValue1;
     write values &amp;amp;colName2 &amp;amp;colValue2;
     write values &amp;amp;colName3 &amp;amp;colValue3;

	   write values "Mitarbeiter";
	   	write open array;
	   	export sub_ma;
	   write close;
	 
	   write values "EFE";
	   	write open array;
	   	export sub_efe;
	   write close; 
   write close; 

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Nov 2018 17:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/509612#M1810</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2018-11-01T17:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc JSON export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/510331#M1928</link>
      <description>OK, I thought this comming. But WHY? SAS has a export-function in JSON, so WHY do I need to put values in macrovariables.... Thumbs down for SAS ;(</description>
      <pubDate>Mon, 05 Nov 2018 06:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/510331#M1928</guid>
      <dc:creator>grimol</dc:creator>
      <dc:date>2018-11-05T06:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: proc JSON export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/512750#M2431</link>
      <description>&lt;P&gt;All software has limitations for various reasons. If you are unhappy with this limitation, you could submit your idea as a SASware Ballot entry.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 21:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/proc-JSON-export/m-p/512750#M2431</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2018-11-13T21:13:02Z</dc:date>
    </item>
  </channel>
</rss>

