Programming the statistical procedures from SAS

Proc glimmix for split plot with three independent variables

Reply
Occasional Contributor
Posts: 7

Proc glimmix for split plot with three independent variables

Hi everyone! First of all sorry for my English, is not my first language and there's probably a lot misspelled words ahead. I'm also new to SAS and I'm trying to run my code for the first time. It's a split plot statistical model where the whole plot is a bull where I analyze "sexo" x "edad" and the split plot is the muscle in which I analyze the type of muscle. I tried this code:

 

Proc glimmix data= castradocruza;
Class edad musc sexo toro;
Model tern_co = Edad | Musc | sexo;
Random toro(edad);
Lsmeans edad Edad | Musc | sexo / pdiff lines;
Run;

 

When I run the code it ends up in the result tab with an invalid data error (picture in the attachment). I've checked all my raw data and so far haven't found an error. Could it be that the code doesn't work for this type of statistical model?

 

 

 

Thanks.

 

PROC Star
PROC Star
Posts: 402

Re: Proc glimmix for split plot with three independent variables

[ Edited ]
Posted in reply to ValeriaRodz

Based on the output you posted, only 6 observations are in your dataset. Your model is a 6 x 6 x 6 factorial in 6 blocks. You cannot fit this model with only 6 observations.

 

You will need either more than 6 observations or a different model. The Community will need more information to provide more help. Please post your SAS code and your dataset (or an example of your dataset).

 

 

Occasional Contributor
Posts: 7

Re: Proc glimmix for split plot with three independent variables

Hi! My raw data was corrupted and only a few observations were showing. I fixed this importing the raw data instead of copy+pasting all of it. 

 

/** Import an XLSX file.  **/

 

PROC IMPORT DATAFILE="/folders/myshortcuts/SASUniversityEdition/Myfolders/word.xlsx"

                                  OUT=WORK.MYEXCEL

                                  DBMS=XLSX

                                  REPLACE;

RUN;

 

/** Print the results. **/

 

PROC PRINT DATA=WORK.MYEXCEL; RUN;

 

 

In regards to the model, I believe its a 2 x 2 x 3 (sex: castrated and intact, muscles: LD, LM and age groups: group 1, 2 and 3). Even though I fixed the problem with the corrupted raw data my code is not working. Probably I'm not using the right one. This is the whole code I was using before I imported the raw data:

data cruza;

input edad $ musc $  sexo $ toro tern_co Col_L Col_a Col_b pH;

datalines;

1 LD i 1 4.9 29.33 20.27 17.91 5.6
1 LM i 1 3.3 44.92 15.46 17.8 5.13
1 LD i 2 2.6 33.22 18.53 17.29 5.55
1 LM i 2 3.6 44.38 14.74 17.66 5.53
1 LD i 3 5.2 38.74 17.49 15.4 5.47
1 LM i 3 3.9 47.97 12.14 14.44 5.51
1 LD i 4 4.5 36.49 15.43 12.05 5.49
1 LM i 4 4.1 44.86 14.32 14.64 5.43
1 LD c 5 4 28.47 19.34 17.22 5.64
1 LM c 5 3.6 47.9 13.02 17.87 5.48
1 LD c 6 3.9 29.57 20.11 16.55 5.49
1 LM c 6 4.4 42.41 16.1 17.13 5.38
1 LD c 7 6.4 33.67 13.82 10.52 5.66
1 LM c 7 3.5 51.67 11.48 15.29 5.62
2 LD i 1 7.4 35.84 21.48 19.73 5.52
2 LM i 1 3.1 42.18 15.83 18.07 5.66
2 LD i 2 4.7 32.12 16.24 11.5 5.54
2 LM i 2 3.5 39.48 15.74 13.24 5.8
2 LD i 3 1.6 27.52 12.71 8.3 5.57
2 LM i 3 2.2 32.95 12.72 9.92 5.29
2 LD i 4 6.6 31.88 18.85 12.78 5.47
2 LM i 4 1.7 43.81 12.96 13.28 6.26
2 LD i 5 4.2 33.35 15.53 11.08 5.94
2 LM i 5 3.7 44.54 12.78 13.52 5.93
2 LD c 6 4 32.35 21.36 19.52 5.51
2 LM c 6 2.8 41.68 17.34 18.9 5.42
2 LD c 7 2.8 34.4 15.96 11.63 5.42
2 LM c 7 3 43.85 15.23 14.98 5.43
2 LD c 8 4.2 37.96 15.01 11.91 5.61
2 LM c 8 2.4 48.28 13.37 15.36 5.58
3 LD i 1 9.6 30.95 15.13 11.43 5.92
3 LM i 1 4.4 37.87 14.27 12.79 5.75
3 LD i 2 6.5 33.78 18.41 13.29 6.78
3 LM i 2 5.2 41.18 16.67 14.65 5.89
3 LD i 3 5.8 32.89 16.03 11.48 5.87
3 LM i 3 8.5 46.38 15.79 15.71 5.85
3 LD i 4 5.9 30.26 15.53 10.17 5.95
3 LM i 4 6.6 36.56 14.05 11.12 5.89
3 LD i 5 4.5 36.49 15.43 12.05 5.49
3 LM i 5 4.1 44.86 14.32 14.64 5.43
3 LD i 6 7.4 35.84 21.48 19.73 5.52
3 LM i 6 3.1 42.18 15.83 18.07 5.66
3 LD i 7 9.7 31.73 14.19 10.61 5.86
3 LM i 7 4.4 38.97 19.47 16.52 5.8
3 LD c 8 3.8 33.16 15.43 11.33 5.97
3 LM c 8 5 42.88 16.69 15.5 5.8
3 LD c 9 5 34.05 16.38 11.67 5.94
3 LM c 9 4.5 45.51 16.17 15.48 5.84
3 LD c 10 7.7 33.44 17.43 12.74 5.96

Run;

proc glimmix data=cruza;

class edad musc sexo toro;

model pH = sexo | musc;

random toro(edad);

lsmeans edad | musc / pdiff lines;

run;

proc glimmix data=cruza;

class edad musc sexo toro;

model Col_L = sexo | musc;

random toro(edad);

lsmeans edad | musc / pdiff lines;

run;

proc glimmix data=cruza;

class edad musc sexo toro;

model Col_a = sexo | musc;

random toro(edad);

lsmeans edad | musc / pdiff lines;

run;

proc glimmix data=cruza;

class edad musc sexo toro;

model Col_b = sexo | musc;

random toro(edad);

lsmeans edad | musc / pdiff lines;

run;

proc glimmix data=cruza;

class edad musc sexo toro;

model Ter_Crd = sexo | musc;

random Toro(Edad);

lsmeans edad | musc / pdiff lines;

run;

proc glimmix data=cruza;

class edad musc sexo toro;

model Ter_Coc = sexo | musc;

random toro(edad);

lsmeans edad | musc / pdiff lines;

run;

 

 

Thanks for answering Smiley Happy 

PROC Star
PROC Star
Posts: 402

Re: Proc glimmix for split plot with three independent variables

Posted in reply to ValeriaRodz

Your original model code is:

 

 

proc glimmix data=cruza;
class edad musc sexo toro;
model Col_a = sexo | musc;
random toro(edad);
lsmeans edad | musc / pdiff lines;
run;

 

Always check the log for any NOTEs, WARNINGs, and ERRORs. For your model, you will see

 

"ERROR: Effects used in the LSMEANS statement must have appeared previously in
the MODEL statement."

 

which pretty clearly tells you what went wrong. (You need to add EDAD to the MODEL statement.)

 

I would consider this code:

 

/* Pattern of observations */
proc tabulate data=cruza;
class edad musc sexo toro;
table edad*sexo*toro, musc;
run;
/* Plot of observed data */
title1 "Col_a"; proc sgpanel data=cruza; panelby sexo; vbox Col_a / group=edad category=musc; run;
/* 3-way full factorial in a split-plot design */ proc glimmix data=cruza plots=(studentpanel boxplot(student fixed)); /* residual plots */ class edad musc sexo toro; model Col_a = edad | sexo | musc; random toro(edad sexo); lsmeans sexo edad musc / pdiff lines; lsmeans sexo*musc / plot=meanplot(join cl sliceby=sexo) slice=(sexo musc); lsmeans edad*musc / plot=meanplot(join cl sliceby=edad) slice=(edad musc) slicediff=musc adjust=simulate(seed=12345); run;

I noticed some issues with the distributions of your response variables. They are not particularly well-behaved data. You may need to transform, check for typos, ponder outliers, etc. 

 

I hope this helps.

 

Occasional Contributor
Posts: 7

Re: Proc glimmix for split plot with three independent variables

Thanks! I checked the notes and errors and it has helped a lot.
Ask a Question
Discussion stats
  • 4 replies
  • 221 views
  • 0 likes
  • 2 in conversation