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

Ok. This might be a ridiculously stupid question easily solved by experienced users.

SAS PROC mixed documentation states the following.

Picture1.png

For the life of me I can't seem to get that statement to work in proc mixed. My variables have a similar lay-out. I am able to specify only A*B and the appropriate controls in the LSmeans statement (without B*C in there). When I add the B*C and specify control levels as in the SAS documentation, I get the error "Wrong number of control levels for A*B" and "Wrong number of control levels for B*C". Am I missing something???

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

I was able to get the error, and I came up with a solution.

First, the levels in the quotes have to be the formatted values in the dataset.  For instance, in my test case, when I had control('1' '1') it failed, as my levels for a were 'Female' and 'Male', so control('Female' '1') works.

Second, when multiple factors are present, the separate parts have to be separated by a comma:

This works for me:

lsmeans sex*group group*week/diff=control('Female' '1' , '1' '1');

This does not:

lsmeans sex*group group*week/diff=control('Female' '1'  '1' '1');

That comma does not appear in the documentation, and is clearly needed.

Steve Denham

View solution in original post

4 REPLIES 4
SteveDenham
Jade | Level 19

Can you share your PROC MIXED code?

This does make a really good case for the use of the LSMESTIMATE statement, though...

Steve Denham

DDK
Obsidian | Level 7 DDK
Obsidian | Level 7

Hello SteveDenham,

The code is really simplified because I wanted to try it out:

proc mixed data=test.testdata;

class a b c;

model y = a b c a*b a*c;

lsmeans a b / pdiff=control('1' '1');

run;

The same problem occurs with the lsmeans statement:

lsmeans a*b  b*c/ pdiff=control('1' '1' '1' '1');


I get output from (each separately):

lsmeans a*b / pdiff=control('1' '1');

or

lsmeans a / pdiff=control('1');

or

lsmeans b*c / pdiff=control('1' '1');

or

lsmeans b / pdiff=control('1');


Once I try to add a factor in the same line as SAS suggests (i.e. lsmeans a*b  b*c/ pdiff=control('1' '1' '1' '1');) , it doesn't work.


If I use :

lsmeans a*b  b*c/ pdiff=control('1' '1');

or

lsmeans a b / pdiff=control('1');


I only get output for a*b or a but not for b*c or b.


It's not a major problem as I of course can specify it separately, but as SAS indicates it is a possibility I wondered why it is not working for me.


SteveDenham
Jade | Level 19

I was able to get the error, and I came up with a solution.

First, the levels in the quotes have to be the formatted values in the dataset.  For instance, in my test case, when I had control('1' '1') it failed, as my levels for a were 'Female' and 'Male', so control('Female' '1') works.

Second, when multiple factors are present, the separate parts have to be separated by a comma:

This works for me:

lsmeans sex*group group*week/diff=control('Female' '1' , '1' '1');

This does not:

lsmeans sex*group group*week/diff=control('Female' '1'  '1' '1');

That comma does not appear in the documentation, and is clearly needed.

Steve Denham

DDK
Obsidian | Level 7 DDK
Obsidian | Level 7

Aha! Thanks Steve!!!! With the comma in there I now can get it to work.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3127 views
  • 0 likes
  • 2 in conversation