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

I am trying to specify several pre-planned comparisons for my PROC MIXED model and using a Bonneferoni adjustment for these comparisons instead of comparing every possible combination using Tukey.

 

The SAS literature says:

"You can specify multiple effects in one LSMEANS statement or in multiple LSMEANS statements, and all LSMEANS statements must appear after the MODEL statement"

 

How do I specifically list the individual comparisons under one LSMEANS statement and have them be adjusted together as one unit?

 

For example:

 

ods graphics on;
PROC MIXED DATA = WORK.Data_Final_noAugust_SS plots(MAXPOINTS=none)=all method=REML;
	CLASS Year Month Cape Site Transect Quadrat;
	MODEL 'Percent.Cover'n = Month Year|Cape/SOLUTION ddfm = KR CL ALPHA=0.05 INTERCEPT outpred=Smooth;
   RANDOM Quadrat(Transect) Transect(Site) Site(Cape) /CL ALPHA=0.05 TYPE=VC;
    LSMEANS Year|Cape / PDIFF CL ALPHA=0.05 ADJUST=TUKEY;
RUN;
ods graphics off;

Year*Cape compares every single combination of Cape (three levels: CF, CP, CB) and Year (three levels: 2016, 2017, 2018). I do not want that; instead, I want specific comparisons with the Bonneferoni adjustment:

 

For example:

CB 2016 vs CB 2017

CB 2017 vs CB 2018

CF 2016 vs CB 2016

CP 2016 vs CB 2016

2016 vs 2017

2017 vs 2018

CF vs CB

CF vs CP

CB vs CP

 

How do I write that?

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You would use the LSMESTIMATE statement.

 

As it says here in the documentation, "Because the analytic features and capabilities of the LSMESTIMATE statement are an amalgam of the LSMEANS and the ESTIMATE statement, the syntax of the statement follows the same pattern."

 

So, if you click on the ESTIMATE statement documentation, you will find examples of estimates of several different comparisons in one statement, and then you can use ADJUST=BON.

--
Paige Miller

View solution in original post

18 REPLIES 18
PaigeMiller
Diamond | Level 26

You would use the LSMESTIMATE statement.

 

As it says here in the documentation, "Because the analytic features and capabilities of the LSMESTIMATE statement are an amalgam of the LSMEANS and the ESTIMATE statement, the syntax of the statement follows the same pattern."

 

So, if you click on the ESTIMATE statement documentation, you will find examples of estimates of several different comparisons in one statement, and then you can use ADJUST=BON.

--
Paige Miller
vitaaquaticus
Fluorite | Level 6

Thank you for the documentation. I read it and I am having difficulty understanding how to write the code exactly.

 

For example:

ods graphics on;
PROC MIXED DATA = WORK.Data_Final_noAugust_SS plots(MAXPOINTS=none)=all method=REML;
	CLASS Year Month Cape Site Transect Quadrat;
	MODEL 'Percent.Cover'n = Month Year|Cape/SOLUTION ddfm = KR CL ALPHA=0.05 INTERCEPT outpred=Smooth;
   RANDOM Quadrat(Transect) Transect(Site) Site(Cape) /CL ALPHA=0.05 TYPE=VC;
    LSMESTIMATE Year*Cape "2016 CB x 2017 CB"
							[1,1,2]
							[-1,1,1],
						  "2017 CB x 2018 CB"
							[1,2,3]
							[-1,1,1]/ ADJUST=BON;
RUN;
ods graphics off;

I keep getting error messages. For this particular code, I get this for the brackets: 

ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, +, -, ]. 

ERROR 200-322: The symbol is not recognized and will be ignored.

PaigeMiller
Diamond | Level 26

Show us the LOG of this PROC MIXED, all of it, the code and the ERROR and WARNING messages, do not chop anything out.

 

Please preserve the formatting of the log by pasting the log from the SAS log window (as text) into the window that appears when you click on the </> icon. This makes the log much more readable and interpretable. DO NOT SKIP THIS STEP. If you skip this step, we will simply repeat the request to perform this step.

--
Paige Miller
vitaaquaticus
Fluorite | Level 6

Here's the log:

1                                                          The SAS System                               07:33 Sunday, April 19, 2020

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='SS_Transects';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='\\Mac\Home\Desktop\ElNinoKelpTransect.egp';
6          %LET _CLIENTPROJECTPATHHOST='BARBARASPIEAEBF';
7          %LET _CLIENTPROJECTNAME='ElNinoKelpTransect.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HtmlBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         ods graphics on;


27         PROC MIXED DATA = WORK.Data_Final_noAugust_SS plots(MAXPOINTS=none)=all method=REML;
28         	CLASS Year Month Cape Site Transect Quadrat;
29         	MODEL 'Percent.Cover'n = Month Year|Cape/SOLUTION ddfm = KR CL ALPHA=0.05 INTERCEPT outpred=Smooth;
30            RANDOM Quadrat(Transect) Transect(Site) Site(Cape) /CL ALPHA=0.05 TYPE=VC;
31             LSMESTIMATE Year*Cape "2016 CB x 2017 CB"
NOTE: PROCEDURE MIXED used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SMOOTH may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.SMOOTH was not replaced because this step was stopped.
32         							[1,1,2]
                      _
                      22
                      200
33         							[-1,1,1],
                       _
                       22
                       200
ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, +, -, ].  
ERROR 200-322: The symbol is not recognized and will be ignored.
34         						  "2017 CB x 2018 CB"
35         							[1,2,3]
                      _
                      22
                      200
36         							[-1,1,1]/ ADJUST=BON;
                       _
2                                                          The SAS System                               07:33 Sunday, April 19, 2020

                       22
                       200
ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, +, -, ].  
ERROR 200-322: The symbol is not recognized and will be ignored.
37         RUN;
38         ods graphics off;
39         
40         GOPTIONS NOACCESSIBLE;
41         %LET _CLIENTTASKLABEL=;
42         %LET _CLIENTPROCESSFLOWNAME=;
43         %LET _CLIENTPROJECTPATH=;
44         %LET _CLIENTPROJECTPATHHOST=;
45         %LET _CLIENTPROJECTNAME=;
46         %LET _SASPROGRAMFILE=;
47         %LET _SASPROGRAMFILEHOST=;
48         
49         ;*';*";*/;quit;run;
50         ODS _ALL_ CLOSE;
51         
52         
53         QUIT; RUN;
54         
PaigeMiller
Diamond | Level 26

I'm thinking you should put the Year*Cape after the "2016 CB x 2017 CB"

--
Paige Miller
vitaaquaticus
Fluorite | Level 6

It adds another error when I put Year*Cape after the text with quotation marks.

 

1                                                          The SAS System                               07:33 Sunday, April 19, 2020

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='SS_Transects';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='\\Mac\Home\Desktop\ElNinoKelpTransect.egp';
6          %LET _CLIENTPROJECTPATHHOST='BARBARASPIEAEBF';
7          %LET _CLIENTPROJECTNAME='ElNinoKelpTransect.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HtmlBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         ods graphics on;


27         PROC MIXED DATA = WORK.Data_Final_noAugust_SS plots(MAXPOINTS=none)=all method=REML;
28         	CLASS Year Month Cape Site Transect Quadrat;
29         	MODEL 'Percent.Cover'n = Month Year|Cape/SOLUTION ddfm = KR CL ALPHA=0.05 INTERCEPT outpred=Smooth;
30            RANDOM Quadrat(Transect) Transect(Site) Site(Cape) /CL ALPHA=0.05 TYPE=VC;
31             LSMESTIMATE "2016 CB x 2017 CB" Year*Cape
                           ___________________
                           22
                           200
NOTE: PROCEDURE MIXED used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SMOOTH may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.SMOOTH was not replaced because this step was stopped.
ERROR 22-322: Expecting a name.  
ERROR 200-322: The symbol is not recognized and will be ignored.
32         							[1,1,2]
                      _
                      22
                      200
33         							[-1,1,1],
                       _
                       22
                       200
ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, +, -, ].  
ERROR 200-322: The symbol is not recognized and will be ignored.
34         						  "2017 CB x 2018 CB"
35         							[1,2,3]
2                                                          The SAS System                               07:33 Sunday, April 19, 2020

                      _
                      22
                      200
36         							[-1,1,1]/ ADJUST=BON;
                       _
                       22
                       200
ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, +, -, ].  
ERROR 200-322: The symbol is not recognized and will be ignored.
37         RUN;
38         ods graphics off;
39         
40         GOPTIONS NOACCESSIBLE;
41         %LET _CLIENTTASKLABEL=;
42         %LET _CLIENTPROCESSFLOWNAME=;
43         %LET _CLIENTPROJECTPATH=;
44         %LET _CLIENTPROJECTPATHHOST=;
45         %LET _CLIENTPROJECTNAME=;
46         %LET _SASPROGRAMFILE=;
47         %LET _SASPROGRAMFILEHOST=;
48         
49         ;*';*";*/;quit;run;
50         ODS _ALL_ CLOSE;
51         
52         
53         QUIT; RUN;
54         
PaigeMiller
Diamond | Level 26

The documentation seems to specify a single quote around the label, rather than a double quote. Please try that. (Although I have never known SAS to be picky about these things except when dealing with macros and macro variables, which is not the case here)

 

If that's not it, the appearance of the ERROR message may indicate that you may have some special non-printing character rather than a space after the word LSMESTIMATE. What happens if you re-type the LSMESTIMATE command from scratch (and no copy and paste allowed)?

--
Paige Miller
vitaaquaticus
Fluorite | Level 6

Seems like the single quote is not the issue here. I tried to re-write the code from scratch and compact them together in fewer lines. Here's the error message: 

1                                                          The SAS System                               07:33 Sunday, April 19, 2020

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='SS_Transects';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='\\Mac\Home\Desktop\ElNinoKelpTransect.egp';
6          %LET _CLIENTPROJECTPATHHOST='BARBARASPIEAEBF';
7          %LET _CLIENTPROJECTNAME='ElNinoKelpTransect.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HtmlBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         ods graphics on;


27         PROC MIXED DATA = WORK.Data_Final_noAugust_SS plots(MAXPOINTS=none)=all method=REML;
28         	CLASS Year Month Cape Site Transect Quadrat;
NOTE: PROCEDURE MIXED used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SMOOTH may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.SMOOTH was not replaced because this step was stopped.
29         	MODEL 'Percent.Cover'n = Month Year|Cape/SOLUTION ddfm = KR CL ALPHA=0.05 INTERCEPT outpred=Smooth;
30            RANDOM Quadrat(Transect) Transect(Site) Site(Cape) /CL ALPHA=0.05 TYPE=VC;
31            LSMESTIMATE Year*Cape '2016 CB x 2017 CB'[1,1,2][-1,1,1],
                                                           _       _
                                                           22      22
                                                           200     200
32         						  '2017 CB x 2018 CB'[1,2,3][-1,1,1]/ ADJUST=BON;
                                          _       _
                                          22      22
                                          200     200
ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, +, -, ].  
ERROR 200-322: The symbol is not recognized and will be ignored.
33         RUN;
34         ods graphics off;
35         
36         GOPTIONS NOACCESSIBLE;
37         %LET _CLIENTTASKLABEL=;
38         %LET _CLIENTPROCESSFLOWNAME=;
39         %LET _CLIENTPROJECTPATH=;
40         %LET _CLIENTPROJECTPATHHOST=;
2                                                          The SAS System                               07:33 Sunday, April 19, 2020

41         %LET _CLIENTPROJECTNAME=;
42         %LET _SASPROGRAMFILE=;
43         %LET _SASPROGRAMFILEHOST=;
44         
45         ;*';*";*/;quit;run;
46         ODS _ALL_ CLOSE;
47         
48         
49         QUIT; RUN;
50         
PaigeMiller
Diamond | Level 26

How many levels of variable YEAR? How many levels of variable CAPE?


Does the code run if you remove the LSMESTIMATE statement?

 

 

--
Paige Miller
vitaaquaticus
Fluorite | Level 6

Cape has 3 levels (CF, CB and CP) and Year has 3 levels (2016, 2017, and 2018). 

 

The code runs fine without the LSMESTIMATE statement.

PaigeMiller
Diamond | Level 26

Okay, I'm out of ideas. You might want to contact SAS Technical Support.

--
Paige Miller
vitaaquaticus
Fluorite | Level 6

Okay, thank you so much for your help! I will reach out to the technical support.

FreelanceReinh
Jade | Level 19

Hi @vitaaquaticus,

 

I don't see any square brackets in the documentation. There should be no brackets at all around the "values" part of the statement.

Edit: Sorry, please see correction in subsequent post.

PaigeMiller
Diamond | Level 26

Square brackets appear in an example here: https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_introcom_sect034.htm&docsetVersio...

 

I have confirmed via a small PROC MIXED with LSMESTIMATE using SASHELP.CLASS that square brackets are not the problem.

--
Paige Miller

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!

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