BookmarkSubscribeRSS Feed
Ana2017
Fluorite | Level 6

Dear:

I run this script to get Least Square means, because I need to know if there are significant differences between each treatment in every single time. 

 

This is the script:

 

LSMEANS Treatment Time;

  LSMEANS Treatment*Time/DIFF SLICE=Time;

 

The problem is that sometimes the chart with LSMEANS does not apprear in the results.

 

Which could be the problem?

 

Thanks.

4 REPLIES 4
Ana2017
Fluorite | Level 6
I mean...
I run the complete script with a set of data and works and then I run again but with other set of data and it does not give the table with de LSMEANS (and also the system does not detect an error).
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

We would need more information to help. I suggest that you follow the recommendations and the link to the SAS Global Forum paper given here

 

https://communities.sas.com/t5/Getting-Started/How-to-get-fast-helpful-answers/ta-p/226133/jump-to/f...

 

In particular, you should provide code, log file, and output, along with your data or example data that produce the same problem.

 

Ana2017
Fluorite | Level 6

 

Hi:

Please find the example of the data and procedure I am using. The problem continues! The table with LSMEANS does not appear, but the system does not generate any error.

 

Thanks!

 

TITLE1 'Lactose';
DATA Lactose;
INPUT
Treatment Animal Time1 Time2 Time3 Time4 Time5 Time6 Time7 Time8 Time9 Time10 Time11 Time12;
DATALINES;
0 1 0.00 34.232 40.329 47.037 48.561 49.171 51.305 53.134 53.134 54.049 54.567 55.317
0 2 0.00 26.519 32.395 36.803 37.697 38.135 38.565 38.565 39.109 39.147 39.890 45.422
0 3 0.00 25.416 33.630 36.367 37.584 37.584 37.888 40.018 41.843 41.843 47.318 50.664
12 4 0.00 23.220 31.850 40.120 51.986 62.055 68.887 72.842 73.202 73.562 73.562 73.562
12 5 0.00 42.391 55.927 64.848 70.385 72.539 72.847 72.847 73.154 73.154 73.154 73.154
12 6 0.00 42.203 57.083 67.408 67.408 67.965 70.749 75.000 75.000 75.000 75.000 75.000
24 7 0.00 26.438 30.264 36.150 45.863 59.107 69.997 69.997 69.997 69.997 75.000 75.000
24 8 0.00 24.593 27.431 31.846 41.305 47.927 47.927 58.963 62.116 63.693 65.269 70.630
24 9 0.00 23.918 26.756 31.171 40.630 47.252 47.252 58.288 61.441 63.018 64.594 69.955
36 10 0.00 33.677 38.445 43.849 50.524 56.563 63.239 67.053 69.914 72.457 72.457 72.457
36 11 0.00 28.643 31.540 37.335 37.335 46.349 55.685 57.294 66.630 70.815 70.815 71.459
36 12 0.00 11.515 12.153 12.153 34.485 42.779 50.755 56.497 57.135 67.344 71.172 72.129
;
RUN;
DATA Lactose;
SET Lactose;
Time=1; Lactose=Time1; OUTPUT;
Time=2; Lactose=Time2; OUTPUT;
Time=3; Lactose=Time3; OUTPUT;
Time=4; Lactose=Time4; OUTPUT;
Time=5; Lactose=Time5; OUTPUT;
Time=6; Lactose=Time6; OUTPUT;
Time=7; Lactose=Time7; OUTPUT;
Time=8; Lactose=Time8; OUTPUT;
Time=9; Lactose=Time9; OUTPUT;
Time=10; Lactose=Time10; OUTPUT;
Time=11; Lactose=Time11; OUTPUT;
Time=12; Lactose=Time12; OUTPUT;
KEEP Treatment Animal Time LACTOSE;
RUN;

%MACRO MIX(HOY, SIGMA);
PROC MIXED DATA=LACTOSE;
CLASS Treatment Animal Time;
MODEL LACTOSE= Treatment |Time /DDFM=KR;
*MAKE SALVA AS TABELAS DE FITING PARA DEPOIS COMPARAR A MELHOR ESTRUCTURA PARA MATRIZ;
MAKE "FITTING" OUT=&HOY(RENAME=(VALUE=V_&HOY));
REPEATED Time/TYPE=&SIGMA SUBJECT=Animal;
RUN;
%MEND MIX;
OPTIONS LS=78 PS=64;
%MIX(MUN,UN);
%MIX (MUN1, UN(1));
%MIX(MCS,CS);
%MIX(MCSH, CSH);
%MIX(MTOEP, TOEP);
%MIX(MAR, AR(1));
%MIX(MVC,VC);
%MIX(MTOEP2, TOEP(2));
%MIX(MARH1, ARH(1));
%MIX(MARMA, ARMA(1,1));
%MIX(MFA1, FA(1));
%MIX(MHF, HF);
%MIX(MANTE1, ANTE(1));
%MIX(MTOEPH, TOEPH);
%MIX(MUNR, UNR);
DATA Resultados;
MERGE MUN MUN1 MCS MCSH MTOEP MAR
MVC MTOEP2 MARH1 MARMA MFA1 MHF MANTE1 MTOEPH MUNR;
PROC PRINT DATA=Resultados;
RUN;
options ps=256 ls=200;

RUN;
DATA LACTOSE;
SET LACTOSE;
KEEP Treatment Animal Time LACTOSE;
RUN;

TITLE2 'UNSTRUCTURED Covariance structure of errors';
PROC MIXED;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=UN
SUBJECT=Animal(Treatment) R RCORR;
RUN;

TITLE2 'Variance Components structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=VC
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Compound Symmetry Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=CS
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Auto-Regressive Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=AR(1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Banded Toeplitz structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=TOEP(2)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Autoregressive Moving Average structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=ARMA(1,1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Toeplitz Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=TOEP
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Banded Main diagonal structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=UN(1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Heterogeneous Autoregressive structure';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Heterogeneous Compound Symmetry structure';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=CSH
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Hyuhn-Feldt Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=HF
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'First-order ante-dependence structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=ANTE(1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Heterogeneous Toeplitz structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=TOEPH
SUBJECT=Animal(Treatment) R RCORR;
RUN;

*****************************************************;
TITLE2 'Auto-Regressive Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=AR(1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Banded Toeplitz structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=TOEP(2)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Autoregressive Moving Average structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ARMA(1,1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Toeplitz Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=TOEP
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Banded Main diagonal structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=UN(1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;

TITLE2 'Heterogeneous Autoregressive structure';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Heterogeneous Compound Symmetry structure';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=CSH
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Hyuhn-Feldt Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=HF
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'First-order ante-dependence structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ANTE(1)
SUBJECT=Animal(Treatment) R RCORR;
RUN;
TITLE2 'Heterogeneous Toeplitz structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=TOEPH
SUBJECT=Animal(Treatment) R RCORR;
RUN;

************************************************************;

TITLE2 'UNSTRUCTURED Covariance structure of errors';
PROC MIXED;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=UN
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Variance Components structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=VC
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Compound Symmetry Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=CS
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Auto-Regressive Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=AR(1)
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Banded Toeplitz structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=TOEP(2)
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Autoregressive Moving Average structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=ARMA(1,1)
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Toeplitz Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=TOEP
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Banded Main diagonal structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=UN(1)
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Heterogeneous Autoregressive structure';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Heterogeneous Compound Symmetry structure';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=CSH
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Hyuhn-Feldt Covariance structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=HF
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'First-order ante-dependence structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=ANTE(1)
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;
TITLE2 'Heterogeneous Toeplitz structure of errors';
PROC MIXED NOCLPRINT NOITPRINT;
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time;
REPEATED Time/ TYPE=TOEPH
SUBJECT=Animal(Treatment) GROUP=Treatment;
RUN;

DATA LACTOSE;
SET LACTOSE;
D=Time;
L=Treatment;
RUN;

TITLE2 'Heterogeneous Autoregressive structure w. RANDOM';
TITLE3 'Final Model with Classes';
PROC MIXED CL COVTEST
PLOTS(UNPACK)=(INFLUENCESTATPANEL RESIDUALPANEL);
CLASS Treatment Animal Time;
MODEL LACTOSE = Treatment|Time/ DDFM=KR
INFLUENCE RESIDUAL;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment);
LSMEANS Treatment Time;
LSMEANS Treatment*Time/ DIFF SLICE=Time;

RUN;

TITLE2 'Heterogeneous Autoregressive structure';
TITLE3 'Final Model as a Polynomial Regression - Iter 1';
PROC MIXED CL COVTEST;
CLASS Treatment Animal Time;
MODEL LACTOSE = L D L*D L*L D*D
L*L*L D*D*D L*L*D D*D*L;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment);

RUN;
TITLE2 'Heterogeneous Autoregressive structure';
TITLE3 'Final Model as a Polynomial Regression - Iter 2';
PROC MIXED CL COVTEST;
CLASS Treatment Animal Time;
MODEL LACTOSE = L D L*D L*L D*D
D*D*D L*L*D D*D*L;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment);
RUN;
TITLE2 'Heterogeneous Autoregressive structure';
TITLE3 'Final Model as a Polynomial Regression - Iter 3';
PROC MIXED CL COVTEST;
CLASS Treatment Animal Time;
MODEL LACTOSE = L D L*D L*L D*D
L*L*D D*D*L;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment);
RUN;
TITLE2 'Heterogeneous Autoregressive structure';
TITLE3 'Final Model as a Polynomial Regression - Iter 4';
PROC MIXED CL COVTEST;
CLASS Treatment Animal Time;
MODEL LACTOSE = L D L*D L*L D*D
L*L*D/SOLUTION;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment);
RUN;

DATA LACTOSE;
SET LACTOSE;
D=D/10;
L=L/100;
RUN;

TITLE2 'Heterogeneous Autoregressive structure';
TITLE3 'Final Model as a Polynomial Regression - Iter 4 bis';
PROC MIXED CL COVTEST;
CLASS Treatment Animal Time;
MODEL LACTOSE = L D L*D L*L D*D
L*L*D/SOLUTION;
RANDOM Animal(Treatment);
REPEATED Time/ TYPE=ARH(1)
SUBJECT=Animal(Treatment);
RUN;

QUIT;
TITLE1;
TITLE2;
TITLE3;
QUIT;

ODS GRAPHICS OFF;
ODS RTF CLOSE;

 

 

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Thank you for the additional information.

 

The code you provide fits 57 or so models, only one of which includes LSMEANS statements. That model does not report an LSMEANS table because the model does not converge. Yes, there was no reported "ERROR" but there is this WARNING in the log file:

 

WARNING: Stopped because of infinite likelihood.

 

WARNINGs and even NOTEs can indicate a bad model; do not look just for ERRORs.

 

You have only 12 animals, and it is overly optimistic to expect that you would be able to adequately estimate a complex covariance structure like the ARH(1)+RE model with the LSMEANS statements in your code. Even if a model with a complex covariance structure converges, it may not be statistically better than a more parsimonious covariance structure. A thoughtful and careful approach to selecting a covariance structure is preferable to a blind "fit all possible structures and see what happens" approach.

 

Are you having problems with the LSMEANS statements for a model with a covariance structure that is well-supported by your data? If so, please provide code that includes only the problematic portion so that we know where to focus our attention: please do not send your entire code.

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1706 views
  • 1 like
  • 2 in conversation