使用SAS宏

使用SAS宏,sas,sas-macro,Sas,Sas Macro,以下是代码: %macro do_regression(dep); proc glimmix data=xxx; class group id intv month1; model &dep = group month1 group*month1/d=normal link=identity; random intv(id); lsmeans group*month1/ilink diff cl ; lsmestimate group*month1 'bsl-3 ' 1 -

以下是代码:

%macro do_regression(dep);

proc glimmix data=xxx;

class group id intv month1;

model &dep = group month1 group*month1/d=normal link=identity;

random intv(id);

lsmeans group*month1/ilink diff  cl ;

lsmestimate group*month1 'bsl-3 ' 1 -1 0 0 -1 1 0 0/cl ;

lsmestimate group*month1 'bsl-6' 1 0 -1 0 -1 0 1 0/cl;

ods output LSMEstimates

run; quit;

%mend;

 

%do_regression(original total domain1)
以下是数据结构的示例:


问:我不熟悉SAS宏,正在使用SAS宏代码为三个结果变量(原始total domain1)运行以下回归模型。我使用:ods output LSMEstimates输出结果,它创建了三个名为data1-data3的数据集,其中包含估计值。但是,我不知道如何附加这些数据集的结果变量名。最后,我只希望将以下内容存储在一个可以“设置”data1-data3的最终数据集中:effect label estimate lower-upper。[我只想存储我正在使用输出的两个lsmestimate语句的估计值:
ods output LSMEstimates
]

来聚合可以使用PROC APPEND的数据集

ods output LSMEstimates=lsm;
run;quit;
proc append data=lsm base=lsm_aggregate force;
run;
如果值/变量&DEP不在ODS OUTPUT语句生成的数据集中,则添加一个步骤来添加它

data lsm_dep ;
  length dep $32 ;
  dep = "&dep";
  set lsm;
run;
proc append data=lsm_dep base=lsm_aggregate force;
run;
在运行新的一批模型之前,请确保删除LSM_聚合数据集

proc delete data=lsm_aggregate; run;
%do_regression(original )
%do_regression(total )
%do_regression(domain1)

你能提供一个小的可行的例子吗?我们无法通过运行此来测试任何内容,因为我们没有任何数据。或者使用SASHELP库中的一个数据集或从GLIMMIX文档示例中查找类似的代码集。@Reeza谢谢。我添加了数据结构的示例。您只是问如何使用ODS输出语句吗<代码>ods输出LSMEstimates=&dep还是你在问如何组合这三个数据集?@Tom谢谢!是的,我想将这些结果设置为单个数据集,并能够确定最终文件中的估计值来自哪个因变量。非常感谢。