BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mbakare
Calcite | Level 5

Hi everyone,

I am analyzing yield trait where a positive value makes sense. The LSMEANS statement in PROC MIXED returns some treatment with negative values. What do I do to prevent from having negative values? What does it mean to have LSMEANS to be negative? My script is as follows:

 
proc mixed data = dsn noitprint noinfo noclprint covtest update;
     by trial_type loc trial;
     class rep  gen ;
     model y = gen prop_hav/ddfm = kr; /* outp returns conditional internally studentized residual*/
     random  rep;
 lsmeans gen;
 ods output lsmeans=dsn._lsmean(keep = trial_type loc trial gen estimate stderr);
 where trial_type not in("CET");
run;
 
quit;
 
 
 

 

 

 

 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You can't force an LSMEANS estimate to be positive. If the math produces a negative LSMEANS value, then that is what you get (and as a side issue, I'm pretty confident that SAS has done thorough quality control on their procedures and the negative number is correct; although certainly bugs do happen). Sometimes this can happen because you have very little data in one cell and large amounts of data in another cell, or perhaps because you have mis-specified the model, or because your x-variables are highly co-linear.

 

By the way, have you checked your input data to make sure you don't have negative values by mistake?

 

If you can't narrow it down to one of the above causes, then you might want to share your data set with SAS technical support and see what explanation they can come up with.

 

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You can't force an LSMEANS estimate to be positive. If the math produces a negative LSMEANS value, then that is what you get (and as a side issue, I'm pretty confident that SAS has done thorough quality control on their procedures and the negative number is correct; although certainly bugs do happen). Sometimes this can happen because you have very little data in one cell and large amounts of data in another cell, or perhaps because you have mis-specified the model, or because your x-variables are highly co-linear.

 

By the way, have you checked your input data to make sure you don't have negative values by mistake?

 

If you can't narrow it down to one of the above causes, then you might want to share your data set with SAS technical support and see what explanation they can come up with.

 

 

--
Paige Miller
mbakare
Calcite | Level 5

Thanks for the prompt response. I suspect that I have few data points in some cells. That is likely to be the reason.

Thanks

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2793 views
  • 0 likes
  • 2 in conversation