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

求助:如何恢复SAS日志显示原始代码的功能?

Hey there, let’s figure out why your SAS log stopped showing original code and only displays green/red comments—this is a common quirk with straightforward fixes, so let’s dive in:

1. Force Enable Source Code Display via System Options

The most likely culprit is that the SOURCE and SOURCE2 system options got toggled off (maybe accidentally via a script or setting change). Run these lines at the very start of your program to re-enable them:

OPTIONS SOURCE SOURCE2;
  • SOURCE controls whether your main program code prints in the log
  • SOURCE2 handles code pulled in via %INCLUDE statements

Since you mentioned Richard’s first option didn’t work, double-check that you’re running these options before executing your main code—sometimes timing or conflicting settings can override this if placed later.

2. Adjust GUI Log Display Preferences

If you’re using the SAS desktop GUI (Base SAS or Enterprise Guide), the log’s display settings might be hiding source code:

  • Base SAS: Go to Tools > Options > Preferences, switch to the Log tab, and make sure the "Source" box is checked under "Items to display".
  • SAS Enterprise Guide: Navigate to Tools > Options > SAS Programs, then under the "Log" section, ensure "Include source code in log" is selected.

These settings sometimes get reset after SAS updates or profile changes, so it’s worth verifying even if you didn’t tweak them manually.

3. Check for Auto-Execute or Startup Scripts

SAS runs auto-execute scripts (like autoexec.sas) at startup, which might be silently setting OPTIONS NOSOURCE; without you realizing. To check this:

  1. Run this line to find your SAS root directory:
    %PUT %SYSGET(SASROOT);
    
  2. Look for an autoexec.sas file in that directory (or ask your admin if your site uses a custom startup script).
  3. If you see OPTIONS NOSOURCE; or OPTIONS NOSOURCE2; in the script, comment those lines out with a * at the start.

4. Test with a Minimal Program

If none of the above work, narrow down the issue by running a super simple test program:

OPTIONS SOURCE SOURCE2;
DATA test;
   x = 1;
RUN;

If this minimal program shows the DATA test; line in the log, the problem is likely specific to your original program (maybe a rogue OPTIONS NOSOURCE; buried in the code somewhere). Search your program for any NOSOURCE or NOSOURCE2 statements and remove them.


内容的提问来源于stack exchange,提问作者Davide Cortellino

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 04:11:42