gpt4 book ai didi

sas - 如何发现是否设置了 SAS 选项或 ODS 选项

转载 作者:行者123 更新时间:2023-12-05 01:21:51 26 4
gpt4 key购买 nike

我经常在 SAS 中编写通用宏。在我的宏中,我想应用一些设置,比如

  • 宏变量
  • SAS 选项
  • ODS 选项

但事后我想“收拾残局”。

对于将是的宏变量

%macro myMac();
%let old_mac_var = &mac_var;

%let mac_var = my_variable;
%put Doing my stuf with &mac_var.;

%let mac_var = &old_mac_var;
%mend;

%let mac_var = value before;
%myMac;
%put mac_var is &mac_var;

(当然我会在实践中使用局部宏变量来解决这个问题,但这不相关。)

但是对于其他设置我该如何做呢?即我如何完成此代码?

%macro test_mprint(should_shouldNot);
data _null_;
put "NOTE: 'data _null_;' &should_shouldNot. be readable here above in the log";
run;
%mend;

%macro myMac();
%let sas_mprint = ...;
%let ods_exclude = ...;

options nomprint;
ods exclude none;

title 'CARS should be printed because of ods option exclude none';
proc print data=sashelp.class;
run;
%test_mprint(should not);

options &sas_mprint.;
ods exclude &ods_exclude.;
%mend;

options mprint;
ods exclude all;
%myMac;

title 'printing CLASS should be avoided by ods option exclude all';
proc print data=sashelp.class;
run;
%test_mprint(should);

最佳答案

SAS 选项很容易检索:

%let sas_mprint = %sysfunc(getoption(mprint));  /* gives, eg, NOMPRINT */

ODS 选项不太确定..

关于sas - 如何发现是否设置了 SAS 选项或 ODS 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36452111/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com