我有以下代码,我试图从宏(写入外部sas文件)中生成独立代码。但是,默认情况下会生成完整的代码并将其写入外部文件。我想知道是否有一种方法可以控制,将宏的哪些部分写入外部文件。感谢所有我能在此上获得的帮助。
%macro tempmacro(outds=);
/* I dont want this following code to be printed */
proc sql noprint;
SELECT cats(name,"=",substr(name,2))
INTO :renames SEPARATED BY " "
FROM dictionary.columns
WHERE LIBNAME="SASHELP" AND MEMNAME=upcase('BASEBALL');
quit;
/* I only Want this following data step printed to the external file */
data &outds;
set sashelp.baseball;
rename &renames;
run;
%mend;
options mfile mprint;
filename mprint "D:\test_code.sas";
data _null_;
file mprint;
%tempmacro(outds=data1);
options nomfile nomprint;
run;
答案 0 :(得分:2)
在option nomprint
之前设置proc sql
,然后在option mprint
之前进行还原。要获得额外的UX点,请在宏开始使用%sysfunc(getoption(mprint))
之前检查选项的值,然后再将其恢复为相同的值。