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

SAS EG宏函数参数自动显示功能跨场景及存储宏适配问询

Solutions for SAS EG Macro Parameter Hints Across Programs & Stored Macros

Great question—this is a common pain point when working with macros in SAS Enterprise Guide! Let’s tackle your two scenarios with practical, elegant solutions:

1. Using Parameter Hints for Macros in Other Programs/Flows

SAS EG’s auto-parameter hint only works for macros defined in the current program because that’s the only code EG parses by default. To extend this to other programs or project flows, you need to make EG aware of the macro definitions globally within your session or project:

  • Store macros in a shared include file: Save your macro definitions (like %test) to a dedicated .sas file (e.g., my_macros.sas). In any program where you need the parameter hint, add an %INCLUDE statement at the top:

    %INCLUDE "C:/SAS/Libraries/Macros/my_macros.sas";
    

    EG will parse this include file and enable hints for all macros inside it.

  • Add the macro folder to SAS’s auto-call library: For even easier access, add your macro folder to the SASAUTOS system option. This tells SAS to automatically load macros from that folder at session start, so you don’t need to manually %INCLUDE them every time:

    OPTIONS SASAUTOS=(SASAUTOS, "C:/SAS/Libraries/Macros");
    

    You can set this permanently in your SAS config file or add it to an EG auto-execution program for your project.

  • Use EG’s project resource library: If you’re working within a single EG project, add your macro definitions to the project’s resources. Right-click your project > Add > Macro, then select your macro file. All programs and flows in the project will now recognize the macros and show parameter hints.

2. Enabling Parameter Hints for Stored Compiled Macros (MSTORE)

Redefining all stored macros with %redefine_all is clunky and risks overwriting existing logic. Instead, create macro stubs—lightweight, empty versions of your stored macros that only include parameter definitions and documentation. EG will use these stubs to display hints, while SAS will still execute the compiled stored macro at runtime.

Here’s how to set this up:

  1. For each stored macro (e.g., %test2), create a stub macro like this:
    %* Stub macro for EG parameter hint — actual compiled macro is in MSTORE library;
    %macro test2(param1=, param2=, param3=);
      %* Parameter descriptions:
      * param1: Input dataset name (required)
      * param2: Output CSV file path (required)
      * param3: Optional flag to enable debug logs (default: NO)
      ;
    %mend test2;
    
  2. Save all these stubs to a single .sas file (e.g., stored_macro_stubs.sas) or separate files in a dedicated folder.
  3. Add this folder to your SASAUTOS path (using the same method as above) or %INCLUDE the stub file in your programs.

Why this works:

When you enable OPTIONS MSTORE, SAS prioritizes compiled stored macros over auto-call library macros at runtime. So EG will use the stub to show parameter hints, but when you run the code, SAS will execute the compiled stored macro instead of the stub—no conflicts, no extra overhead.

You can even use conditional compilation to ensure stubs only load in EG (not in batch mode) to avoid any potential issues:

%IF &_CLIENTAPP. = "SAS Enterprise Guide" %THEN %DO;
  %* Load stubs only in EG for parameter hints;
  %INCLUDE "C:/SAS/Libraries/Macros/stored_macro_stubs.sas";
%END;

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:10:09