BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
peiy5920
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
blueskyxyz
Lapis Lazuli | Level 10
/*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);

View solution in original post

7 REPLIES 7
ChrisNZ
Tourmaline | Level 20

Your explanations are unclear. To me at least. What data do you have? What data do you want? What do you want to automate?

peiy5920
Calcite | Level 5
I already solved my problem. I will try to put more detailed information about my question. I'm sorry.
blueskyxyz
Lapis Lazuli | Level 10
/*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);
peiy5920
Calcite | Level 5
Thank you for your examples. It is helpful!
blueskyxyz
Lapis Lazuli | Level 10
😊 welcome.
blueskyxyz
Lapis Lazuli | Level 10
reference : https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_mixed_sect0...

some advices:
1.see the example in the user guide
2. list the statistics you need and sample datasets
peiy5920
Calcite | Level 5
Thank you for your information.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1089 views
  • 0 likes
  • 3 in conversation