BookmarkSubscribeRSS Feed
jchlapecka
Calcite | Level 5

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;

4 REPLIES 4
ballardw
Super User

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.

SteveDenham
Jade | Level 19

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

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 4 replies
  • 490 views
  • 3 likes
  • 5 in conversation