<?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 Need to create a SAS dataset from a JSON file- its in text format. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319054#M69980</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently working with a new site's API.&amp;nbsp; I have the JSON file but ,sence this is a new website, its in a different format from a previous post.&amp;nbsp;&amp;nbsp; I need to convert this JSON file, that is in text format, into a SAS dataset.&amp;nbsp; Attached is the JSON text file.&lt;/P&gt;&lt;P&gt;Here is the code that I used to process this file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename out "X:\BLSSeriesDataOut.txt" recfm=v lrecl=32000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.pulljson;&lt;/P&gt;&lt;P&gt;infile out dsd lrecl=300000000 dlm='[]{},:';&lt;/P&gt;&lt;P&gt;input x : $2000. @@;&lt;/P&gt;&lt;P&gt;retain flag;&lt;/P&gt;&lt;P&gt;if x ='seriesID' then flag=1;&lt;/P&gt;&lt;P&gt;if x='footnotes' then group+1;&lt;/P&gt;&lt;P&gt;if flag and x not in (' ' 'seriesID' 'footnotes');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(not sure how to continue )&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;&l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&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;"&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;"&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Wed, 14 Dec 2016 21:15:20 GMT</pubDate>
    <dc:creator>yo1</dc:creator>
    <dc:date>2016-12-14T21:15:20Z</dc:date>
    <item>
      <title>Need to create a SAS dataset from a JSON file- its in text format.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319054#M69980</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently working with a new site's API.&amp;nbsp; I have the JSON file but ,sence this is a new website, its in a different format from a previous post.&amp;nbsp;&amp;nbsp; I need to convert this JSON file, that is in text format, into a SAS dataset.&amp;nbsp; Attached is the JSON text file.&lt;/P&gt;&lt;P&gt;Here is the code that I used to process this file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename out "X:\BLSSeriesDataOut.txt" recfm=v lrecl=32000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.pulljson;&lt;/P&gt;&lt;P&gt;infile out dsd lrecl=300000000 dlm='[]{},:';&lt;/P&gt;&lt;P&gt;input x : $2000. @@;&lt;/P&gt;&lt;P&gt;retain flag;&lt;/P&gt;&lt;P&gt;if x ='seriesID' then flag=1;&lt;/P&gt;&lt;P&gt;if x='footnotes' then group+1;&lt;/P&gt;&lt;P&gt;if flag and x not in (' ' 'seriesID' 'footnotes');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(not sure how to continue )&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;&lt;P&gt;Here is the example output format&amp;nbsp;of what I want to acheive.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;YEAR&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Period&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;PeriodName&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Value&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;1999&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;M12&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;December&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1520&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;1999&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;5200&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2200&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;"&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;"&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;"&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 14 Dec 2016 21:15:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319054#M69980</guid>
      <dc:creator>yo1</dc:creator>
      <dc:date>2016-12-14T21:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a SAS dataset from a JSON file- its in text format.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319068#M69989</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can make use of the @'someText' column pointer capability to read in this data. In case you have SAS9.4M4 you can use the JSON libname engine. Both techniques are shown below. To test out the JSON libname engine, you can download the latest version of the SAS University Edition, it comes with SAS9.4M4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename fjson "c:\temp\BLSSeriesDataOut.json";

/*in case you have SAS9.4M4*/
/*libname ljson json FILEREF=fjson;*/
/**/
/*proc copy in=ljson out=work;*/
/*run;*/


data ds_data;
  infile fjson lrecl=99999999 dlm="," dsd;
  input
    @'"year":' year : 4.
    @'"period":' period : $3.
    @'"periodName":' periodName : $32.
    @'"value":' value : 8.
    @@
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 22:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319068#M69989</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2016-12-14T22:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a SAS dataset from a JSON file- its in text format.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319184#M70030</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
 infile '/folders/myfolders/BLSSeriesDataOut.txt' dsd lrecl=30000000 dlm='{}[]:,';
 input x : $2000.@@;
run;
data temp;
 merge x x(firstobs=2 rename=(x=_x));
 if lowcase(x) in ("year","period","periodname","value");
run;
data temp;
 set temp;
 if lowcase(x)='year' then group+1;
run;

proc transpose data=temp out=want(drop=_:);
by group;
id x;
var _x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Dec 2016 07:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319184#M70030</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-15T07:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a SAS dataset from a JSON file- its in text format.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319320#M70099</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You might want to take a look at&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;36aeae18.1612c" target="_blank"&gt;https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;36aeae18.1612c&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 16:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319320#M70099</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2016-12-15T16:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a SAS dataset from a JSON file- its in text format.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319322#M70101</link>
      <description>&lt;P&gt;Thanks Burno.&amp;nbsp; This code worked for me.&amp;nbsp; On my end I don't have the availablity of PROC GROOVY or PROC JSON.&amp;nbsp; I have to work within the context of the DATA step.&amp;nbsp; However, with everyone help I am getting better.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 17:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319322#M70101</guid>
      <dc:creator>yo1</dc:creator>
      <dc:date>2016-12-15T17:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a SAS dataset from a JSON file- its in text format.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319323#M70102</link>
      <description>&lt;P&gt;Thanks Ksharp.&amp;nbsp;&amp;nbsp; The code you provided&amp;nbsp;not only provided the output but gave me a better understanding on how to approach these situaitons.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 17:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319323#M70102</guid>
      <dc:creator>yo1</dc:creator>
      <dc:date>2016-12-15T17:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a SAS dataset from a JSON file- its in text format.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319325#M70104</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the URL provided didn't seem to work.&amp;nbsp; It directed me to a login page for some reason.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 17:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-create-a-SAS-dataset-from-a-JSON-file-its-in-text-format/m-p/319325#M70104</guid>
      <dc:creator>yo1</dc:creator>
      <dc:date>2016-12-15T17:02:31Z</dc:date>
    </item>
  </channel>
</rss>

