Reputation: 6930
Here is code:
%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)
Here is example of data structure:
Question: I am new to SAS macros and am working with a SAS macro code to run the following regression model for three outcome variables (original total domain1). I output the results using: ods output LSMEstimates which created three datasets named data1—data3 with the estimates. However, I cannot figure out how to attach the outcome variable names of these datasets. Eventually, I would only want the following to be stored in one final dataset that can “set” data1—data3: effect label estimate lower upper. [I only want to store estimates from the two lsmestimate statements shown that I am outputting using: ods output LSMEstimates
]
Upvotes: 0
Views: 156
Reputation: 51566
To aggregate the datasets you can use PROC APPEND.
ods output LSMEstimates=lsm;
run;quit;
proc append data=lsm base=lsm_aggregate force;
run;
If the value/variable &DEP is not already in the dataset generated by the ODS OUTPUT statement then add a step to add it.
data lsm_dep ;
length dep $32 ;
dep = "&dep";
set lsm;
run;
proc append data=lsm_dep base=lsm_aggregate force;
run;
Make sure to remove the LSM_AGGREGATE dataset before running a new batch of models.
proc delete data=lsm_aggregate; run;
%do_regression(original )
%do_regression(total )
%do_regression(domain1)
Upvotes: 1