<?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 SAS Stored Process ERROR: File is in use, _WEBOUT . in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Stored-Process-ERROR-File-is-in-use-WEBOUT/m-p/938217#M368559</link>
    <description>&lt;P&gt;Hi, I’m creating a web page via a stored process. This web page calls another stored process which should return the JSON of a SAS table via the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;proc json out=_webout&lt;/CODE&gt;. When I make the request, I get this error:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE&gt;ERROR: File is in use, _WEBOUT.
ERROR: Due to the previous error, the JSON output file is incomplete and invalid, or in some cases, unable to be created. If created, the JSON output file is retained so that you can review it to help determine the cause of the error.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;I’m using SAS 9.4&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What can I do to resolve this problem?&lt;BR /&gt;&lt;BR /&gt;this is code sas:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;%put &amp;amp;=data_format;

filename filecsv "ttt_&amp;amp;data_format..csv";

%stpbegin;
%macro check_file_exists;

    %if %sysfunc(fexist(filecsv)) %then %do;
		%put 'The file filecsv  exist';
       	data ttt;
		    infile filecsv truncover firstobs=2;
		    input a b $26. c $ d $ e $ f $60.  ;

		run;

		proc json out=_webout pretty;
			write open object;
			write values "data";
			write open array;
			export ttt / nokeys nosastags;
			write close;
			write close;
			write close;
		run;

    %end;
    %else %do;
        %put 'The file filecsv does not exist';
    %end;

    
%mend check_file_exists;

%check_file_exists;

%stpend;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Aug 2024 10:23:19 GMT</pubDate>
    <dc:creator>rakeon3</dc:creator>
    <dc:date>2024-08-05T10:23:19Z</dc:date>
    <item>
      <title>SAS Stored Process ERROR: File is in use, _WEBOUT .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Stored-Process-ERROR-File-is-in-use-WEBOUT/m-p/938217#M368559</link>
      <description>&lt;P&gt;Hi, I’m creating a web page via a stored process. This web page calls another stored process which should return the JSON of a SAS table via the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;proc json out=_webout&lt;/CODE&gt;. When I make the request, I get this error:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE&gt;ERROR: File is in use, _WEBOUT.
ERROR: Due to the previous error, the JSON output file is incomplete and invalid, or in some cases, unable to be created. If created, the JSON output file is retained so that you can review it to help determine the cause of the error.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;I’m using SAS 9.4&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What can I do to resolve this problem?&lt;BR /&gt;&lt;BR /&gt;this is code sas:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;%put &amp;amp;=data_format;

filename filecsv "ttt_&amp;amp;data_format..csv";

%stpbegin;
%macro check_file_exists;

    %if %sysfunc(fexist(filecsv)) %then %do;
		%put 'The file filecsv  exist';
       	data ttt;
		    infile filecsv truncover firstobs=2;
		    input a b $26. c $ d $ e $ f $60.  ;

		run;

		proc json out=_webout pretty;
			write open object;
			write values "data";
			write open array;
			export ttt / nokeys nosastags;
			write close;
			write close;
			write close;
		run;

    %end;
    %else %do;
        %put 'The file filecsv does not exist';
    %end;

    
%mend check_file_exists;

%check_file_exists;

%stpend;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 10:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Stored-Process-ERROR-File-is-in-use-WEBOUT/m-p/938217#M368559</guid>
      <dc:creator>rakeon3</dc:creator>
      <dc:date>2024-08-05T10:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Stored Process ERROR: File is in use, _WEBOUT .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Stored-Process-ERROR-File-is-in-use-WEBOUT/m-p/938221#M368562</link>
      <description>&lt;P&gt;My guess when you call %sptbegin, it is generating an ODS statement that directs output to _webout.&amp;nbsp; So you could try removing %stpbegin and %stpend, and see if that works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you might also need to set content type headers to tell the browser the content is a json file.&amp;nbsp; See this related post:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/td-p/394032" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/td-p/394032&lt;/A&gt;&amp;nbsp;.&amp;nbsp; I like Bruno's suggestion to write the json to a file, so you can see the file, then you can stream the file to _webout.&amp;nbsp; I think you could do it something like (untested):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data _null_;
    file _webout recfm=s;
    infile "&amp;amp;myinfile" recfm=n;
    if _n_ = 1 then do;
      rc = stpsrv_header('Content-type','application/json');
      rc = stpsrv_header('Content-disposition',"attachment; filename=MyJson");
    end;
    input c $char1.;
    put c $char1. @@;
  run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That's code to do a binary copy of a file from an old post I can't find now &lt;A href="https://support.sas.com/kb/6/588.html" target="_blank"&gt;https://support.sas.com/kb/6/588.html&lt;/A&gt; , but there are better ways.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 12:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Stored-Process-ERROR-File-is-in-use-WEBOUT/m-p/938221#M368562</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-08-05T12:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Stored Process ERROR: File is in use, _WEBOUT .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Stored-Process-ERROR-File-is-in-use-WEBOUT/m-p/938251#M368565</link>
      <description>Hi, I have resolved by removing %stpbegin and %stpend and the options / nokeys nosastags,&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 05 Aug 2024 17:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Stored-Process-ERROR-File-is-in-use-WEBOUT/m-p/938251#M368565</guid>
      <dc:creator>rakeon3</dc:creator>
      <dc:date>2024-08-05T17:02:05Z</dc:date>
    </item>
  </channel>
</rss>

