A "Fileref Deassign Failure for _WEBOUT" message appears in the SAS Stored Process Server log file


The following error appears in the SAS Stored Process Server log file after a stored process completes execution:

Fileref Deassign Failure for _WEBOUT

The error indicates that the _WEBOUT fileref was not properly closed at the end of the stored process. The most common scenarios that result in this error are outlined below—the parts of the code that are commented provide examples of the code that can be added to prevent the error from occurring.

Scenario 1

The stored process source code uses the FOPEN function to open the _WEBOUT fileref but fails to properly close the fileref with the FCLOSE function.

Here is an example:

data _null_;
rc = stpsrv_header('Content-type',"text/xml");
length rec $4096;
filein = fopen('response','I',4096,'B');
fileid = fopen('_WEBOUT','O',4096,'B');
rec = " ";
do while(fread(filein)=0);
rc = fget(filein,rec,4096);
rc = fput(fileid,rec);
rc = fwrite(fileid);
end;
/* Use the FCLOSE function to close the _WEBOUT fileref */
rc = fclose(fileid);
run;

Scenario 2

The stored process source code uses the %STPBEGIN macro but does not include the %STPEND macro that closes the _WEBOUT fileref.

Here is an example:

%stpbegin;
proc print data=sashelp.cars;
run;
/* Include the %STPEND macro to close the _WEBOUT fileref */
%stpend;

Scenario 3

The stored process source code uses ODS statements that write to _WEBOUT but does not include the correct ODS statement to close the output destination.

Here is an example:

ods html file=_webout;
proc print data=sashelp.air;
run;
/* Use the appropriate ODS statement to close the _WEBOUT fileref; this example uses the HTML destination */
​​​​​​​ods html close;