<?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: Import JSON schema into an empty SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803244#M316285</link>
    <description>&lt;P&gt;You need to give the libname engine two text files.&amp;nbsp; One with the actual JSON text to read and one with the MAP file that tells the JSON libref engine how to convert the JSON into SAS dataset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually I just use the same name for both the libref and the filename that points to the actual JSON text.&amp;nbsp; You then need a second fileref that points to either an existing MAP file or the location you want SAS to autogenerate one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your SAS code might look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename json 'some file with actual json text';
filename map 'some file with the mapping';
libname json json fileref=json map=map;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to convert the file named&amp;nbsp;"C:\JSON_Schema.json" to a SAS dataset then treat as the actual JSON text and not the MAP.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Mar 2022 23:21:01 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-03-21T23:21:01Z</dc:date>
    <item>
      <title>Import JSON schema into an empty SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803222#M316274</link>
      <description>&lt;P&gt;Need help to import a JSON schema into an empty SAS dataset.&amp;nbsp; I have the schema file but no data yet.&amp;nbsp; Tried this syntax but get an ERROR: Invalid Physical Name, ERROR: in the LIBNAMD statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename map "C:\JSON_Schema.json";
libname JSONlib json map=map;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Direct read of the JSON schema as a data file creates a separate dataset for each field in the schema:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname JSONdata json 'c:\JSON_Schema.json';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is getting a preview of the eventual SAS dataset file structure even possible?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 20:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803222#M316274</guid>
      <dc:creator>Haris</dc:creator>
      <dc:date>2022-03-21T20:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Import JSON schema into an empty SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803244#M316285</link>
      <description>&lt;P&gt;You need to give the libname engine two text files.&amp;nbsp; One with the actual JSON text to read and one with the MAP file that tells the JSON libref engine how to convert the JSON into SAS dataset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually I just use the same name for both the libref and the filename that points to the actual JSON text.&amp;nbsp; You then need a second fileref that points to either an existing MAP file or the location you want SAS to autogenerate one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your SAS code might look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename json 'some file with actual json text';
filename map 'some file with the mapping';
libname json json fileref=json map=map;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to convert the file named&amp;nbsp;"C:\JSON_Schema.json" to a SAS dataset then treat as the actual JSON text and not the MAP.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 23:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803244#M316285</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-21T23:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Import JSON schema into an empty SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803247#M316287</link>
      <description>&lt;P&gt;Thanks for your input, TOM.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The thing is I only have the SCHEMA (I assume it's the same thing as the MAP but is it?) but no actual data to convert.&amp;nbsp; Here is the first variable -- the unique identifier:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;{  "$schema" : "http://json-schema.org/draft-04/schema#",
   "type" : "array",
	"items" : {
		"additionalProperties" : false,
		"properties" : {
			"dxout_identifier": {
				"type" : "string",
				"maxLength" : 255
			},&lt;BR /&gt;...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I received the schema ahead of the arrival of the actual data so that I could examine the file structure and prepare the code that will stack this new version on top of an older version of the same dataset with some new variables and some deletions and some format changes.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 23:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803247#M316287</guid>
      <dc:creator>Haris</dc:creator>
      <dc:date>2022-03-21T23:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Import JSON schema into an empty SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803250#M316288</link>
      <description>&lt;P&gt;Does not look like the format of the MAP files that JSON libname engine uses.&lt;/P&gt;
&lt;P&gt;You could try to convert that into a definition of a dataset and/or all the way into a MAP so that you are ready when the real file comes.&amp;nbsp; You should ask for an example with a few dummy records you can use to test it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could try converting by hand.&amp;nbsp; Or if it is really large perhaps you could convert that JSON into some SAS datasets and then use a program to use that write a MAP file for SAS.&amp;nbsp; Or perhaps just regular SAS code to define the dataset(s) you will need to create from the JSON text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example it looks like there is a variable named DXOUT_IDENTIFIER that should be defined as length $255.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 00:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-JSON-schema-into-an-empty-SAS-dataset/m-p/803250#M316288</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-22T00:29:38Z</dc:date>
    </item>
  </channel>
</rss>

