You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调试向_webout写入PDF的Stored Process Web应用,规避CACHE访问方法报错

Fixing the "CACHE access method" Error When Writing PDF to _webout in SAS Stored Processes

Hey there, let's work through this frustrating error you're hitting when trying to output a PDF to _webout in your Stored Process Web app. That "Function is only valid for filerefs using the CACHE access method" message usually pops up because _webout isn't configured correctly for binary file output (which PDFs require) or lacks the CACHE access method your PDF-generating functions need. Here are actionable fixes to try:

1. Properly Configure _webout with CACHE and Binary Mode

Your previous attempts with filename _webout temp or dummy didn't include the critical parameters for binary output and CACHE access. Try this instead at the start of your Stored Process:

/* Clear any existing _webout reference first */
filename _webout clear;
/* Set _webout to a temp file with binary format and CACHE access */
filename _webout temp recfm=f lrecl=80 access=cache;
  • recfm=f sets fixed record format, which is required for binary files like PDFs
  • lrecl=80 is a standard buffer size for binary transfers
  • access=cache explicitly enables the access method your PDF functions need

2. Pair with ODS PDF Directly

Make sure you're using ODS PDF to write directly to the configured _webout fileref, rather than relying on other file-writing functions that might not respect the CACHE setting:

/* Close all open ODS destinations first to avoid conflicts */
ods _all_ close;

/* Generate PDF directly to _webout */
ods pdf file=_webout notoc startpage=no;
  /* Your PDF content code goes here (proc report, data steps, etc.) */
  proc report data=sashelp.class nowindows;
  run;
ods pdf close;
  • notoc and startpage=no are optional tweaks—adjust based on your PDF layout needs

3. Check Stored Process Execution Settings

Don't overlook the SAS Management Console configuration for your Stored Process:

  • Navigate to your Stored Process in SAS Management Console
  • Go to Execution Options
  • Set Output Type to Binary or Raw (not Text!)—this ensures the web server handles the PDF as a binary file, preventing corruption and access method issues

4. Use a Temporary File Workaround (If Direct Write Fails)

If the above steps still don't work, try generating the PDF to a temporary file first, then copying it to _webout:

/* Create a temp file with CACHE access for PDF generation */
filename pdftemp temp recfm=f lrecl=80 access=cache;

ods pdf file=pdftemp notoc;
  /* Your PDF content code */
  proc print data=sashelp.iris;
  run;
ods pdf close;

/* Copy the temp PDF to _webout */
data _null_;
  infile pdftemp recfm=f lrecl=80;
  file _webout recfm=f lrecl=80;
  input;
  put _infile_;
run;

/* Clean up the temp file */
filename pdftemp clear;

This workaround isolates the PDF generation in a properly configured fileref, then transfers the binary data to _webout directly.

Final Notes

Always make sure to clear existing _webout references and close unused ODS destinations at the start of your Stored Process—leftover settings from previous sessions can cause unexpected errors like this.

内容的提问来源于stack exchange,提问作者Allan Bowe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:14:40