如何创建名称与数据集字段对应的 SAS html 文件

How can I create SAS html files with names corresponding to a dataset field

我正在尝试为我的 SAS 数据集中的每条记录创建一个文件。通过使用 "newfile=page" 选项,然后简单地 运行 数据集上的过程报告,我已经能够使用 SAS ODS 输出成功地做到这一点。我遇到的问题是,这会导致通用的、按顺序编号的文件名(测试、测试 1、测试 2 等)。我想根据数据集中的变量命名每个文件。在下面的示例中,我希望文件名的标题基于数据集中的 "seq_nbr"。

    ods html path = "C:\test\"
    file = 'test.html'
    contents = 'contents.html
    frame = 'frame.html'
    code = (url="C:\test\javascript.js")
    newfile=page;

    proc report data = test2 nowindows headline headskip;
    column tDate tTime created_by cmtText;
    by seq_nbr;

    run;

你需要一个宏

%macro doit;
proc sql;
select count(*) into :n from test2 ;
quit;

%do i=1 %to &n;
data _null_;
if _n_=&i call symput('name',seq_nbr);
run;

proc export data=something outfile="&name";
run;
%end;

%mend;
%doit;