0
votes

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: enter image description here

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]

1
Can you provide a small workable example? We can't test anything by running this because we don't have any data. Or find a similar set of code using one of the data sets in the SASHELP library or from the GLIMMIX documentation examples.Reeza
@Reeza Thank you. I added example of data structure.vasili111
Are you just asking how to use the ODS OUTPUT statement? ods output LSMEstimates=&dep; Or are you asking how to combine the three datasets?Tom
@Tom Thank you! Yes I would like to set each of these results in to a single dataset and be able to identify which dependent variable the estimates in the final file are from.vasili111

1 Answers

1
votes

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)