Hello, I'm having problems with SAS giving me incorrect means. I've got two missing data points but it all ready correctly in my PROC PRINT step...Any help would be appreciated! I've also attached my data text file.
Here is the code below:
TITLE1 '2022 NewLeaf NUE Trials' ;
DATA MORVT;
INFILE 'C:\Users\jlcdtv\OneDrive - University of Missouri\Documents\2022 Research\2022 Company Trials\NewLeaf NUE Trials.txt' firstobs=3 obs=134 DLM='09'x DSD;
INPUT TestNo$ TestName$ Site$ Trt Treatment$ Plot Rep EScore StandCt Stand Vigor HeadDate$ Julian CanopyHt Weight Moisture TestWt Yield;
RUN ;
ods html close;
ods rtf file='C:\Users\jlcdtv\OneDrive - University of Missouri\Documents\2022 Research\2022 Company Trials\2022 NewLeaf NUE.rtf' style=journal bodytitle;
PROC PRINT DATA=MORVT ;
QUIT ;
PROC GLIMMIX DATA=MORVT;
CLASS Trt Site;
MODEL Yield= Trt Site Trt*Site/ ddfm=kr dist=gamma link=log;
RANDOM rep;
ods exclude Dimensions FitStatistics OptInfo IterHistory;
LSMEANS Trt Site Trt*Site / ilink lines;
output out=new pred=predicted resid=residual student=student;
RUN;
proc print data=new noobs label;;
var plot site rep yield residual student;
where abs(student) > 2.5;
run;
ods rtf close;
Show the LOG for the Proc Glimmix. Copy the from the log the code and all messages from running the code.
You do not mention which variable you know has "2 missing values". If it is one of the variables Trt or Sites then by default any record with missing values will be excluded from the model and there would typically be a note in the log about how many observations were used by the procedure.
Proc print has nothing to do with means, so I am not sure why you mention that. Plus you have two Proc Print calls shown. So which one are you meaning to reference.
Least squares means are not arithmetical averages. They are the expected values IF the data are balanced. You have missing values. Consequently, the lsmeans will not be equal to the means.
SteveDenham
As indicated elsewhere, the LSMEAN is not a simple arithmetic average of the observations. It is an estimate (prediction) based on the model. The arithmetic means will only agree with LSMEANS under very specific (limited) situations. Furthermore, the LSMEANS for a non-normal distribution will definitely not be equivalent to an arithmetic average of the raw data points.
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: