BookmarkSubscribeRSS Feed
jugomauabc
Calcite | Level 5

 

Hi everyone. Mi name is Juan. I have a repeated measurement data with tree treatments: A (n=4), B (n=4) and C (n=4). The response variable (body temperature) was measured 30 times in each subject. Unfortunately, I have some missing values. I am using PROC MIXED to evaluate the effect of treatment of the response variable:

 

proc mixed data=tmp3;

CLASS Treatment ID Time;

MODEL Temperature= Treatment Time Treatment*time/Residual;

REPEATED / SUB=ID (Treatment) TYPE=AR(1);

RANDOM ID (Treatment);

LSMEANS Treatment Treatment*time/ PDIFF ADJUST=TUKEY;

run;

 

After I ran the program, I have the next statement in the LOG window: WARNING: The R matrix depends on observation order within subjects. Omitting observations from the analysis because of missing values can affect this matrix. Consider using a classification effect in the REPEATED statement to determine ordering in the R matrix.

 

SAS is unable to calculate the effect of treatment or the least square means for each treatment. ¿How can I solve this problem?

 

Thanks for your help

2 REPLIES 2
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10

This warning message arises when the data set is not sorted by subject and time, and this causes SAS to be "unsure" about the ordering of effects. In general, when your longitudinal data set is sorted by subject and time, you can omit the "time" classification variable from the repeated statement (see the documentation). When, however, the data is not sorted properly, PROC MIXED is thrown off.This is a very-quickly simulated data set and set of procedures that illustrates the issue. Notice that the final PROC MIXED statement runs without the Warning statement after the input data set is sorted and Time is explicitly added to the REPEATED statement.

data want;
  do i = 1 to 50;
    do group = 'A';
    do time = 1, 2, 3, 4; 
    do y = rand('Normal' , 0, 1);output;
	end;
	end; end; end;
  do i = 51 to 100;
    do group = 'B';
    do time = 1, 2, 3, 4; 
    do y = rand('Normal' , 1, 2);output;
	end;
	end; end; end;
	run;
proc sort data=want;
   by i y;
   run;
proc mixed data=want;
class i group;
   model y = time|group;
   REPEATED / SUB=i (group) TYPE=AR(1);
   run;
data broken; /*Add some missing values into the data set*/
   set want;
   if i = 4 and time =3 then do; time = .; y = . ; end;
      if i = 40 and time =2 then time = .;
	  run;
proc mixed data=broken; /*This replicates your warning message*/
class i group;
   model y = time|group;
   REPEATED / SUB=i (group) TYPE=AR(1);
   run;

proc sort data=broken out=fixed;
   by i time;
   run;

proc mixed data=fixed;
class i group time;
   model y = time|group;
   REPEATED time / SUB=i (group) TYPE=AR(1);
   run;
jugomauabc
Calcite | Level 5

Dear SVH:

 

Thanks for your help. It works very well.

 

Best regards.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 485 views
  • 1 like
  • 2 in conversation