代码之家  ›  专栏  ›  技术社区  ›  babsdoc

我可以有条件地将语句打印到外部SAS程序文件吗?

  •  1
  • babsdoc  · 技术社区  · 8 年前

    我有以下代码,我试图从宏生成一个独立的代码(写入外部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;
    
    1 回复  |  直到 8 年前
        1
  •  2
  •   user667489    8 年前

    套 option nomprint 在你的 proc sql 然后 option mprint 然后再恢复。对于额外的UX点数,请在使用之前检查选项的值 %sysfunc(getoption(mprint)) 在宏的开头,然后将其还原为相同的值。

    推荐文章