Programming the statistical procedures from SAS

Contrast and Estimate statements: observation order within subjects

Posts: 27

Contrast and Estimate statements: observation order within subjects

I am trying to incorporate CONTRAST and ESTIMATE statements to analyze the difference in growth rates of trees.

I uncovered a code that was used in a previous study that did precisely what i want, however, the way the data was entered, and therefore the code was written, is different. The previous data set was imported from an excel sheet in which each growth parameter for each date was entered in separate columns, ie- GLD0306, GLD0706, GLD0707 etc. The current data sheet has the growth parameter as a single column with Date as a separate column. The other variable in question, either Fert or Nfix, will be Y or N.

the code that was used before was:

Data Loggrow;
set yr6growth;
lgld1=log10(gld0306);   lgld2=log10(gld0706);   lgld3=log10(gld0707);   lgld4=log10(gld0711);
array lglda{4} lgld1 lgld2 lgld3 lgld4;
do i = 1 to 4;
if (i = 1) then MTH = 9;
else if (i = 2) then MTH = 12;   else if (i = 3) then MTH = 24;   else if (i = 4) then MTH = 72;
Time = MTH;   MTHC = MTH;
log10gld = lglda{i};
drop i gld0306 gld0706 gld0707 gld0711 ht0306 ht0706 ht0707 ht0711 lgld1 lgld2 lgld3 lgld4;

proc mixed data=loggrow order=data covtest nobound;
where spc = "Parica";
class BLK fert nfix MTH ID;
model log10gld = fert nfix mth fert*nfix fert*mth nfix*mth fert*nfix*mth;
random BLK fert*BLK nfix*fert*BLK nfix*fert*BLK*ID;
repeated /subject=nfix*fert*blk*ID type=sp(pow) (mth) r rcorr;
LSMEANS FERT mth fert*mth/pdiff =all adjust = tukey;
LSMEANS fert*mth/slice=mth;
contrast 'diff y-n, mth 72-24' fert*mth 0 0 1 -1 0 0 -1 1;
estimate 'diff y-n, mth 72-24' fert*mth 0 0 1 -1 0 0 -1 1;


When running this code withe new spreadsheet format, i get a "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."


The part that is confusing me is the in the Contrast and Estimate statements, since each of the months was assigned a different "i". However, in the new data set spread sheet, Date is its own column as is the growth variable (as opposed to having multiple growth variable columns, one for each date), and i do not understand how to order the subjects or how to write the classification effect to satisfy the code.

My question is this:
How to write the Contrast and Estimate statements to incorporate the new format?


These are the column headers and a row of data for the new data set:

Posts: 401

Re: Contrast and Estimate statements: observation order within subjects

Regarding the WARNING statement: The WARNING is suggesting that you specify the <repeated-effect> in the REPEATED statement; see the documentation REPEATED statement. It would be something like


repeated mth / subject=blk*fert*nfix*id type=sp(pow)(c-list);


where c-list is a numeric variable (which means it would not appear in the CLASS statement).


Regarding CONTRAST and ESTIMATE statements: This paper addresses your questions in detail. In particular, consider using the LSMESTIMATE statement rather than the CONTRAST or ESTIMATE statement; LSMESTIMATE makes writing contrasts and estimates easier and less error-prone.


You didn't ask, but I would think that if you want to analyze growth "rate", then you would need to apply an appropriate regression model for the response over time. But I know essentially nothing about your study design or the definitions of your variables, so this is just speculation on my part.


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation