使用 SAS 宏
Using 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 -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 宏代码运行 三个结果变量(原始总域 1)的以下回归模型。我使用以下方法输出结果:ods output LSMEstimates,它创建了三个名为 data1—data3 的数据集和估计值。但是,我不知道如何附加这些数据集的结果变量名称。最终,我只希望将以下内容存储在一个可以“设置”data1-data3 的最终数据集中:效果标签估计下上。 [我只想存储我输出的两个 lsmestimate 语句的估计值:ods output LSMEstimates
]
要聚合数据集,您可以使用 PROC APPEND。
ods output LSMEstimates=lsm;
run;quit;
proc append data=lsm base=lsm_aggregate force;
run;
如果 value/variable &DEP 不在 ODS OUTPUT 语句生成的数据集中,则添加一个步骤来添加它。
data lsm_dep ;
length dep ;
dep = "&dep";
set lsm;
run;
proc append data=lsm_dep base=lsm_aggregate force;
run;
确保在 运行 一批新模型之前删除 LSM_AGGREGATE 数据集。
proc delete data=lsm_aggregate; run;
%do_regression(original )
%do_regression(total )
%do_regression(domain1)
代码如下:
%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 宏代码运行 三个结果变量(原始总域 1)的以下回归模型。我使用以下方法输出结果:ods output LSMEstimates,它创建了三个名为 data1—data3 的数据集和估计值。但是,我不知道如何附加这些数据集的结果变量名称。最终,我只希望将以下内容存储在一个可以“设置”data1-data3 的最终数据集中:效果标签估计下上。 [我只想存储我输出的两个 lsmestimate 语句的估计值:ods output LSMEstimates
]
要聚合数据集,您可以使用 PROC APPEND。
ods output LSMEstimates=lsm;
run;quit;
proc append data=lsm base=lsm_aggregate force;
run;
如果 value/variable &DEP 不在 ODS OUTPUT 语句生成的数据集中,则添加一个步骤来添加它。
data lsm_dep ;
length dep ;
dep = "&dep";
set lsm;
run;
proc append data=lsm_dep base=lsm_aggregate force;
run;
确保在 运行 一批新模型之前删除 LSM_AGGREGATE 数据集。
proc delete data=lsm_aggregate; run;
%do_regression(original )
%do_regression(total )
%do_regression(domain1)