Sas 使用excel标记集导出到excel。

Sas 使用excel标记集导出到excel。,sas,sas-macro,Sas,Sas Macro,我想通过excel标记集将数据集的内容导出到excel工作表中, 然而,我为5个数据集编写了5次代码 我想写一个宏,将库中的变量列表连接到数据集列表,这样我就不必多次写入proc内容 我写的基本代码如下: ods tagsets.excelxp file="c:\ECT2013_Mappning1.xls" style=statistical options( skip_space='3,2,0,0,1' sheet_interval='none' sheet_name='

我想通过excel标记集将数据集的内容导出到excel工作表中, 然而,我为5个数据集编写了5次代码

我想写一个宏,将库中的变量列表连接到数据集列表,这样我就不必多次写入proc内容

我写的基本代码如下:

    ods tagsets.excelxp file="c:\ECT2013_Mappning1.xls" style=statistical

      options( skip_space='3,2,0,0,1' sheet_interval='none' sheet_name='Datasets'     
suppress_bylines='no');

proc datasets library=work; quit;run;
 ods tagsets.excelxp options( skip_space='3,2,0,0,1' sheet_interval='none'    
sheet_name='Behtid' suppress_bylines='no');

Proc contents data=behtid varnum;run;
 ods tagsets.excelxp options( skip_space='3,2,0,0,1' sheet_interval='none' 
sheet_name='Biverk' suppress_bylines='no');

Proc contents data=biverk varnum;run;
 ods tagsets.excelxp options( skip_space='3,2,0,0,1' sheet_interval='none' 
sheet_name='Dosering' suppress_bylines='no');

ods tagsets.excelxp close;
我想写一个宏,它会自动连接数据集,并根据库中可用的数据集数量执行带有proc内容的excel标记集。
我该怎么做

我们的宏应该可以在有或没有工作簿路径的情况下调用,因此工作簿路径必须是可选的。 Sas宏知道两种类型的参数:位置必填(此处用于工作表)和按名称可选(此处用于工作簿)

第一次包含可选参数时,以后不包含

%excelOds(Datasets,workBook=c:\ECT2013_Mappning1.xls);
proc datasets library=work; quit;run;

%excelOds(Behtid);
Proc contents data=behtid varnum;run;

** and so further **;

ods tagsets.excelxp close;

您知道如何编写宏和/或SAS宏如何工作吗?您是否考虑过改用SASHELP.VCOLUMN表?然后,您可以使用一些ODS标记集By选项自动命名工作表,而无需创建宏。
%excelOds(Datasets,workBook=c:\ECT2013_Mappning1.xls);
proc datasets library=work; quit;run;

%excelOds(Behtid);
Proc contents data=behtid varnum;run;

** and so further **;

ods tagsets.excelxp close;