Hi,
My table like this
outcomes intervention time for control time for intervention p
Beta(s.e.) Beta(s.e.) Beta(s.e.)
SCE
SCMT
SM
SP
my sas code is
proc mixed data=Scores covtest;
class Subject_ID;
model SCE=intervention time intervention*time/solution;
random intercept /subject=Subject_ID;
run;
I want to use macro to create the table. I checked the ODS table names in mixed mode, but I still have no idea that how to start. Can someone give me some suggestions? Thanks in advance.
/*take an example*/
data heart;
set sashelp.heart;
subject=strip(put(_n_,best.));
if n(AgeAtDeath,AgeAtStart)=2 then livetime=AgeAtDeath-AgeAtStart+1;
run;
***1.to see which stat you need to output in log and result window;
ods trace on;
proc mixed data=heart covtest;
class Weight_Status BP_Status Subject;
model livetime=Weight_Status BP_Status Weight_Status*BP_Status/solution;
random intercept /subject=Subject;
run;
ods trace off;
***2.output the datasets;
ods output Tests3=Tests3 ClassLevels=ClassLevels;
proc mixed data=heart covtest;
class Weight_Status BP_Status Subject;
model livetime=Weight_Status BP_Status Weight_Status*BP_Status/solution;
random intercept /subject=Subject;
run;
***use macro;
%macro mixed(var=);
ods output Tests3=Tests3 ClassLevels=ClassLevels;
proc mixed data=heart covtest;
class Weight_Status BP_Status Subject;
model &var=Weight_Status BP_Status Weight_Status*BP_Status/solution;
random intercept /subject=Subject;
run;
%mend;
%mixed(var=a);
%mixed(var=b);
Your explanations are unclear. To me at least. What data do you have? What data do you want? What do you want to automate?
/*take an example*/
data heart;
set sashelp.heart;
subject=strip(put(_n_,best.));
if n(AgeAtDeath,AgeAtStart)=2 then livetime=AgeAtDeath-AgeAtStart+1;
run;
***1.to see which stat you need to output in log and result window;
ods trace on;
proc mixed data=heart covtest;
class Weight_Status BP_Status Subject;
model livetime=Weight_Status BP_Status Weight_Status*BP_Status/solution;
random intercept /subject=Subject;
run;
ods trace off;
***2.output the datasets;
ods output Tests3=Tests3 ClassLevels=ClassLevels;
proc mixed data=heart covtest;
class Weight_Status BP_Status Subject;
model livetime=Weight_Status BP_Status Weight_Status*BP_Status/solution;
random intercept /subject=Subject;
run;
***use macro;
%macro mixed(var=);
ods output Tests3=Tests3 ClassLevels=ClassLevels;
proc mixed data=heart covtest;
class Weight_Status BP_Status Subject;
model &var=Weight_Status BP_Status Weight_Status*BP_Status/solution;
random intercept /subject=Subject;
run;
%mend;
%mixed(var=a);
%mixed(var=b);
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.