<?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: Edit raw json file prior to using proc json in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532943#M32983</link>
    <description>&lt;P&gt;SAS is reading it in in scientific notation&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the following values&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1545317114383&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Comes out as such&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1.5453171E12&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Feb 2019 14:56:43 GMT</pubDate>
    <dc:creator>Sean_OConnor</dc:creator>
    <dc:date>2019-02-05T14:56:43Z</dc:date>
    <item>
      <title>Edit raw json file prior to using proc json</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532889#M32978</link>
      <description>&lt;P&gt;Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to edit a raw json file prior to reading it into SAS for analysis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is raw data I'm using and code I'm using which I would like to extend.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Raw data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;{"time_stamp":1545314383,"empId":"4215-4-1","unregistered":false}
{"time_stamp":154534383,"empId":"4215-4-1","unregistered":false}
{"time_stamp":15454383,"empId":"425-4-1","unregistered":false}
{"time_stamp":15454383,"emId":"4915-1","unregistered":false}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile json2 end=eof;
  file json3 ;
  input ;
  if _n_=1 then put '[' @; else put ',' @;
  put _infile_;
  if eof then put ']';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How data is changed&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;[{"time_stamp":1545314383,"empId":"4215-4-1","unregistered":false}
,{"time_stamp":154534383,"empId":"4215-4-1","unregistered":false}
,{"time_stamp":15454383,"empId":"425-4-1","unregistered":false}
,{"time_stamp":15453383,"emId":"4915-1","unregistered":false}
]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I would like to extend the code to turn the time_stamp variable to character as I'm running into issues when it's read into SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I would like the following&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;{"time_stamp":"1545314383","empId":"4215-4-1","unregistered":false}
{"time_stamp":"154534383","empId":"4215-4-1","unregistered":false}
{"time_stamp":"15454383","empId":"425-4-1","unregistered":false}
{"time_stamp":"154531383","emId":"4915-1","unregistered":false}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 11:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532889#M32978</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2019-02-05T11:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Edit raw json file prior to using proc json</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532939#M32981</link>
      <description>&lt;P&gt;You do not explain what problem you are having with the time_stamp field data when read into SAS. If you are using the &lt;A href="https://go.documentation.sas.com/?docsetId=lestmtsglobal&amp;amp;docsetTarget=n1jfdetszx99ban1rl4zll6tej7j.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p1bwa176ppg0ydn135d8wl01vdcm" target="_self"&gt;JSON LIBNAME engine&lt;/A&gt; note that you can modify the resultant map file and assign a format to the time_stamp field. This may solve your problem.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 14:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532939#M32981</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2019-02-05T14:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Edit raw json file prior to using proc json</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532941#M32982</link>
      <description>&lt;P&gt;Not exhaustively tested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	length InString $32767;
	retain _RX1;
	infile json2 end=eof;
	file json3;
	input;
	InString = _infile_;

	if _n_=1 then do;
		_RX1 = prxparse('s~\{"time_stamp":([[:digit:]]*),"empId":"~{"time_stamp":"$1","empId":"~');
		put '[' @;
	end;
	else put ',' @;
	call prxchange(_RX1, -1, InString);
	put InString;

	if eof then
		put ']';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 14:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532941#M32982</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-02-05T14:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Edit raw json file prior to using proc json</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532943#M32983</link>
      <description>&lt;P&gt;SAS is reading it in in scientific notation&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the following values&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1545317114383&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Comes out as such&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1.5453171E12&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 14:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532943#M32983</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2019-02-05T14:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Edit raw json file prior to using proc json</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532948#M32984</link>
      <description>&lt;P&gt;No need to change the JSON file. Just change the MAP file that says how to convert it.&lt;/P&gt;
&lt;P&gt;If you let SAS generate the map then you will have a definition like this for time_stamp.&lt;/P&gt;
&lt;PRE&gt;       {
          "NAME": "time_stamp",
          "TYPE": "NUMERIC",
          "PATH": "/root/time_stamp"
        },&lt;/PRE&gt;
&lt;P&gt;Which you can just change to this to have it make it as a character string of length 20.&lt;/P&gt;
&lt;PRE&gt;       {
          "NAME": "time_stamp",
          "TYPE": "CHARACTER", "LENGTH": 20,
          "PATH": "/root/time_stamp"
        },&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 15:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532948#M32984</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-05T15:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Edit raw json file prior to using proc json</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532983#M32985</link>
      <description>Hi Tom,&lt;BR /&gt;&lt;BR /&gt;I'm just wondering is it possible to add labels at this stage too? So I would like to have labels for my variables in my stamp too?</description>
      <pubDate>Tue, 05 Feb 2019 16:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532983#M32985</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2019-02-05T16:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Edit raw json file prior to using proc json</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532986#M32986</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=n1jfdetszx99ban1rl4zll6tej7j.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=n1jfdetszx99ban1rl4zll6tej7j.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;name, type, length, format, informat, label&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 16:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532986#M32986</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-05T16:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Edit raw json file prior to using proc json</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532990#M32987</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116786"&gt;@Sean_OConnor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;SAS is reading it in in scientific notation&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the following values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1545317114383&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Comes out as such&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1.5453171E12&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is likely a byproduct of a generic import routine assigning a default format of BEST12. to the values.&lt;/P&gt;
&lt;P&gt;Please see the below code:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   x=1545317114383;
   put "Best12. format" x= best12. "Best13. format" x= best13.;
run;&lt;/PRE&gt;
&lt;P&gt;Note the different appearance of the value as shown in the log with different format.&lt;/P&gt;
&lt;P&gt;You can change the format after the data is imported to a preferred appearance either manually or with Proc Datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 16:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Edit-raw-json-file-prior-to-using-proc-json/m-p/532990#M32987</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-05T16:20:48Z</dc:date>
    </item>
  </channel>
</rss>

