<?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 error: ERROR: Due to the previous error, the JSON output file is incomplete and invali in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738630#M230442</link>
    <description>&lt;P&gt;The problem is triggered by the fact that the width on the format is not long enough to include 2 decimal places for that value.&amp;nbsp; Not sure why it triggers an in PROC JSON in not other places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;See the difference in output between percent7.2 and percent8.2:&lt;/P&gt;
&lt;PRE&gt;657   data json_sample1;
658      percentvar=0.543;
659      format percentvar percent8.2;
660      put '----5----0'/ percentvar percent7.2 / percentvar percent8.2 ;
661   run;

----5----0
 54.3%
 54.30%&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you can add some pre output step to confirm that the formats attached to the variables being written do not also have the same issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you can use a user defined format to print the data?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
picture xx  (round ) 
  other = '009.99%' (mult=100)
;
run;

data json_sample1;
   percentvar=0.543;
   format percentvar xx.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 May 2021 16:27:58 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-05-03T16:27:58Z</dc:date>
    <item>
      <title>proc json error: ERROR: Due to the previous error, the JSON output file is incomplete and invalid</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738511#M230382</link>
      <description>&lt;P&gt;I got error when running output to json using "proc json".&lt;/P&gt;&lt;P&gt;The program and error message you can see bellow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I have to use "fmtnumeric" options for my needs. This is not an option for me.&lt;/P&gt;&lt;P&gt;2. When I use "format percentvar percent&lt;STRONG&gt;10&lt;/STRONG&gt;.2" instead of percent7.2 it is working, but&amp;nbsp; maximum length of numeric variable is unknown.&amp;nbsp;This is also not an option for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data json_sample1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;percentvar=0.543;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;format percentvar percent7.2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc json out="/tmp/r1.json" nosastags pretty;&lt;/P&gt;&lt;P&gt;&amp;nbsp; write open object;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; write values data;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;write open array;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;export json_sample1 / fmtnumeric;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;write close;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;write close;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: Due to the previous error, the JSON output file is incomplete and invalid, or in some cases,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;unable to be created. If created, the JSON output file is retained so that you can review it&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;to help determine the cause of the error.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 08:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738511#M230382</guid>
      <dc:creator>sashamal</dc:creator>
      <dc:date>2021-05-03T08:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc json error: ERROR: Due to the previous error, the JSON output file is incomplete and invali</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738572#M230413</link>
      <description>&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p0c7jsl3orer8fn14dll459ifzmm.htm" target="_self"&gt;PERCENTw.d Format&amp;nbsp;&lt;/A&gt;(see Syntax Description section)&lt;/P&gt;
&lt;P&gt;I tested this and it looks like you need to specify&amp;nbsp;the&lt;SPAN&gt;&amp;nbsp;width of the output field to account for the percent sign % and parentheses () for numbers, whether the number is negative or positive.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Your example number 0.543, is would be formatted "(54.30%)" and needs a minimum of 8 characters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could convert the number (percentvar) into a string and output that:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;strPct=putn(percentvar,"percent7.2") ;&lt;BR /&gt;&lt;BR /&gt;Then your JSON file would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;{
  "data": [
    {
      "strPct": "(54.3%)"
    }
  ]
}
&lt;/PRE&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>Mon, 03 May 2021 12:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738572#M230413</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-05-03T12:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc json error: ERROR: Due to the previous error, the JSON output file is incomplete and invali</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738604#M230431</link>
      <description>&lt;P&gt;Hello AMSAS. Thank your reply, but as was mentioned I can't use other formats or covert numeric data to character. I use JSON output in automated server to server communication and I have no possibility for any manual changes. The same bug in Proc JSON appears when using &lt;STRONG&gt;comma&lt;/STRONG&gt;d.w formats and possible other numeric SAS formats. May be SAS can fix this in next release? In such case, no need to stop generation of json and send message of fatal error, just output data in regular SAS form, like in all others procedures or dataset steps.&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 14:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738604#M230431</guid>
      <dc:creator>sashamal</dc:creator>
      <dc:date>2021-05-03T14:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc json error: ERROR: Due to the previous error, the JSON output file is incomplete and invali</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738622#M230439</link>
      <description>&lt;P&gt;This issue is probably best addressed via a SAS Technical Support track.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/en/technical-support/contact-sas.html" target="_blank"&gt;https://support.sas.com/en/technical-support/contact-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 15:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738622#M230439</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-05-03T15:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc json error: ERROR: Due to the previous error, the JSON output file is incomplete and invali</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738630#M230442</link>
      <description>&lt;P&gt;The problem is triggered by the fact that the width on the format is not long enough to include 2 decimal places for that value.&amp;nbsp; Not sure why it triggers an in PROC JSON in not other places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;See the difference in output between percent7.2 and percent8.2:&lt;/P&gt;
&lt;PRE&gt;657   data json_sample1;
658      percentvar=0.543;
659      format percentvar percent8.2;
660      put '----5----0'/ percentvar percent7.2 / percentvar percent8.2 ;
661   run;

----5----0
 54.3%
 54.30%&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you can add some pre output step to confirm that the formats attached to the variables being written do not also have the same issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you can use a user defined format to print the data?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
picture xx  (round ) 
  other = '009.99%' (mult=100)
;
run;

data json_sample1;
   percentvar=0.543;
   format percentvar xx.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 May 2021 16:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738630#M230442</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-03T16:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: proc json error: ERROR: Due to the previous error, the JSON output file is incomplete and invali</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738687#M230467</link>
      <description>&lt;P&gt;Since the single error message you post includes: "&lt;FONT color="#FF0000"&gt;ERROR: Due to the previous error,&lt;/FONT&gt;" I wonder if there actually was a previous error message and if so how it appears.&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 19:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738687#M230467</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-03T19:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: proc json error: ERROR: Due to the previous error, the JSON output file is incomplete and invali</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738839#M230525</link>
      <description>&lt;P&gt;&lt;EM&gt;"Perhaps you can add some pre output step to confirm that the formats attached to the variables being written do not also have the same issue?"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can add pre-check, but I have no ideas how can I validate such formats.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 10:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738839#M230525</guid>
      <dc:creator>sashamal</dc:creator>
      <dc:date>2021-05-04T10:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc json error: ERROR: Due to the previous error, the JSON output file is incomplete and invali</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738842#M230528</link>
      <description>&lt;P&gt;No any previous errors here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can execute bellow code to see this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data json_sample1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;percentvar=0.543;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;format percentvar percent7.2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc json out="/tmp/r1.json" nosastags pretty;&lt;/P&gt;&lt;P&gt;&amp;nbsp; write open object;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; write values data;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;write open array;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;export json_sample1 / fmtnumeric;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;write close;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;write close;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 10:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-json-error-ERROR-Due-to-the-previous-error-the-JSON-output/m-p/738842#M230528</guid>
      <dc:creator>sashamal</dc:creator>
      <dc:date>2021-05-04T10:30:28Z</dc:date>
    </item>
  </channel>
</rss>

