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

Hi, I am working with repeated measurement analysis with two treatment factors and day.  The result outputs do not give letter annotation for the mean separation.  So I am wondering how to do it since proc glm will work but not proc mixed 

 

Data RM;

  set RM;

  A_new = A + 1;

  A_sq = sqrt(A_new);

  A_log = log(A_new);

run;

 

ods graphics on;

 

proc sort data= RM;

by EU Day;

run;

 

%macro one(type);

proc mixed data= RM cl plots=residualpanel (conditional) plot=boxplot (conditional); /*Test assumption */

      class Block Day Accession Irrigation EU;

 

model A_log = Accession Day Irrigation Accession*Day Accession*Irrigation Irrigation*Day Accession*Irrigation*Day / ddfm=satterth; /*Satterthwaite ddf are requested.

Without this specification, Proc Mixed may give erroneous ddf for repeated measures,*/

      Random Block;

      repeated Day / subject=EU type=&type r rcorr;

      lsmeans Accession Day Irrigation Accession*Day Accession*Irrigation Irrigation*Day Accession*Irrigation*Day/adjust=Tukey;

%mend one; /*"%mend" indicates the end of the macro*/

%one(un); /*each time we write "%one" we are calling up the macro and running it with the type of Covariance structure designated in the parenthesis.  For example, on this line we are saying, "Run the macro "one" using the unstructured covariance matrix" ("unstructured" means all variances and covariances are estimated separately) */

%one(cs);

%one(csh);

/*%one(ar(1)); */

/*%one(arh(1)); */

/*%one(toep); */

/*%one(toeph); */

%one(ante(1));

run;

ods graphics off;

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ
%LET type=toeph;

proc mixed data= RM cl plots=residualpanel (conditional) plot=boxplot (conditional); 
      class Block Day Accession Irrigation EU;
      model A_log = Accession Day Irrigation 
                    Accession*Day Accession*Irrigation Irrigation*Day Accession*Irrigation*Day 
                     / ddfm=satterth;
      Random Block;
      repeated Day / subject=EU type=&type r rcorr;
      lsmeans       Accession Day Irrigation 
                    Accession*Day Accession*Irrigation Irrigation*Day Accession*Irrigation*Day
                     / adjust=Tukey;
   store ABCXYZ / label='PLM: Getting Started';
run;

proc plm restore=ABCXYZ;
   lsmeans Accession*Irrigation / lines linestable;
   ods output LSMLines=LSMLines;
run;
/* end of program */

Koen

View solution in original post

15 REPLIES 15
sbxkoenk
SAS Super FREQ

You want this?

 

This is a paper from SUGI 23 (SUGI --> SAS Global Forum --> SAS Explore).
I believe SUGI 23 was in 2003 or so.

 

A Macro for Converting Mean Separation Output to Letter Groupings in PROC MIXED
Arnold M. Saxton, University of Tennessee Agricultural Experiment Station
Knoxville, Tennessee
https://support.sas.com/resources/papers/proceedings/proceedings/sugi23/Stats/p230.pdf

 

Koen

ngui
Calcite | Level 5

Thank you for the information. I did the extra codes in my code but I got an error showing ! %pdmix612(DIFFSDATASET, LSMEANSDATASET, alpha=0.05, sort=NO, worksize=1); Error; incoccerct5INCLUDE statement will not be executed. There is a syntax error. WARNING: Apparent invocation of macro PDMIX612 not resolved.

Do you know what is happening?

 
 
Data RM;
  set RM;
  A_new = A + 1;
  A_sq = sqrt(A_new);
  A_log = log(A_new);
run;
 
ods graphics on;
 
proc sort data= RM; 
by EU Day;
run;
 
%macro one(type);
proc mixed data= RM cl plots=residualpanel (conditional) plot=boxplot (conditional);
class Block Day Accession Irrigation EU;
 
model A_new = Accession Day Irrigation Accession*Day Accession*Irrigation Irrigation*Day Accession*Irrigation*Day / ddfm=satterth; /*Satterthwaite ddf are requested. 
Without this specification, Proc Mixed may give erroneous ddf for repeated measures,*/
Random Block;
repeated Day / subject=EU type=&type r rcorr;
lsmeans Accession Day Irrigation Accession*Day Accession*Irrigation Irrigation*Day Accession*Irrigation*Day/adjust=Tukey pdiff;
 
/* Save LSMEANS into a dataset (e.g., LSMEANSDATASET) */
  make lsmeans out=LSMEANSDATASET noprint;
 
  /* Save pairwise differences into a dataset (e.g., DIFFSDATASET) */
  make diffs out=DIFFSDATASET noprint;
 
run;
 
/* Include the external macro %pdmix612 and call it to perform letter annotation */
%include A:PDMIX612.SAS;
%pdmix612(DIFFSDATASET, LSMEANSDATASET, alpha=0.05, sort=NO, worksize=1);
 
 
%mend one; /*"%mend" indicates the end of the macro*/
%one(un); /*each time we write "%one" we are calling up the macro and running it with the type of Covariance structure designated in the parenthesis.  For example, on this line we are saying, "Run the macro "one" using the unstructured covariance matrix" ("unstructured" means all variances and covariances are estimated separately) */
/*%one(ar(1)); */
/*%one(arh(1)); */
/*%one(toep); */
/*%one(toeph); */
%one(ante(1));
run;
ods graphics off;
sbxkoenk
SAS Super FREQ

Hello,

 

The %INCLUDE statement has a wrong syntax

(hence the macro was not compiled and hence does not "exist" for your SAS session) :

Instead of :

%include A:PDMIX612.SAS;

you need something like :

%include 'C:\Users\ABC_XYZ\Downloads\PDMIX612.SAS' / source2;

BR,
Koen

ngui
Calcite | Level 5
Can I know where can I get or download the A:PDMIX612.SAS?

Is it something that I can create or I need to get from somewhere
sbxkoenk
SAS Super FREQ

@ngui wrote:
Can I know where can I get or download the A:PDMIX612.SAS?
Is it something that I can create or I need to get from somewhere

Hello,

 

The paper says (on page 4) :

The macro code pdmix612.sas can be obtained by anonymous FTP from the server SCS1.AG.UTK.EDU.

That will probably no longer work.
You can try to contact the author (if e-mail address still correct).

 

Moreover you need SAS/IML (SAS module with Interactive Matrix Language)
and maybe SAS/IML is not in your license key.

 

Maybe you should follow suggestion by @data_null__ and use LINES option in PROC PLM.

 

BR,
Koen

ngui
Calcite | Level 5
I am using SAS9.4 and it is installed on my computer. Will it be the same as SAS/IML?
sbxkoenk
SAS Super FREQ

@ngui wrote:
I am using SAS9.4 and it is installed on my computer. Will it be the same as SAS/IML?

Hello,

 

PROC GLM and PROC MIXED (and PROC PLM) are part of a SAS 9.4 module called SAS/STAT.
SAS/IML is another SAS module (some MATLAB like thing with a matrix language for linear algebra and matrix operations).

 

To see whether SAS/IML is in your license key, you need to submit :

proc setinit; run;

Then you need to see (something like) this in your LOG-screen :

---SAS/IML
     14JUL2024 (CPU A)
---SAS/IML Studio
     14JUL2024 (CPU A)

BR, Koen

data_null__
Jade | Level 19

Seems like you might be able to use LINES option with PROC PLM

 

data_null___0-1695071317232.png

 

sbxkoenk
SAS Super FREQ

Here is doc for PROC PLM.

The PLM procedure performs Post-fitting (Linear Model) statistical analyses for the contents of a SAS item store that was previously created with the STORE statement in some other SAS/STAT procedure (like PROC MIXED).

 

SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation
SAS/STAT 15.3 User's Guide
The PLM Procedure
LSMEANS Statement
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_plm_syntax06.htm

 

Koen

ngui
Calcite | Level 5
I am not familiar with PROC PLM. Would you mind helping me check my data set and see whether it will be suitable for PROC PLM?
data_null__
Jade | Level 19

This might help.

 

data BlockDesign;
   input block a b y @@;
   datalines;
   1 1 1  56  1 1 2  41
   1 2 1  50  1 2 2  36
   1 3 1  39  1 3 2  35
   2 1 1  30  2 1 2  25
   2 2 1  36  2 2 2  28
   2 3 1  33  2 3 2  30
   3 1 1  32  3 1 2  24
   3 2 1  31  3 2 2  27
   3 3 1  15  3 3 2  19
   4 1 1  30  4 1 2  25
   4 2 1  35  4 2 2  30
   4 3 1  17  4 3 2  18
;

proc mixed data=BlockDesign;
   class block a b;
   model y = a b a*b / solution;
   random block;
   store BlockAnalysis / label='PLM: Getting Started';
   run;
ods trace on;
proc plm restore=blockanalysis;
   lsmeans a*b / lines linestable;
   ods output LSMLines=LSMLines;
   run;
ods trace off;
proc contents varnum;
proc print;
   run;

 

data_null___0-1695076564973.png

 

sbxkoenk
SAS Super FREQ

Hello,

 

Here's an example with PROC GLIMMIX (instead of PROC MIXED).
The crucial part is the STORE statement:

proc glimmix data=multicenter;
 class center group;
 model sideeffect/n = group / solution;
 random intercept / subject=center;
 store gmx;
run;
proc plm source=gmx;
 lsmeans group / cl ilink;
run;

gmx is the name of the item store.

Using item stores and PROC PLM enables you to perform separate common post-processing tasks, CONTRASTS, ESTIMATES, LSMEANS, and LSMESTIMATES for a mixed-model analysis.

 

Koen

ngui
Calcite | Level 5
Thank you for the info. I am confused about how to integrate proc plm into my code. Can you help me out
sbxkoenk
SAS Super FREQ
%LET type=toeph;

proc mixed data= RM cl plots=residualpanel (conditional) plot=boxplot (conditional); 
      class Block Day Accession Irrigation EU;
      model A_log = Accession Day Irrigation 
                    Accession*Day Accession*Irrigation Irrigation*Day Accession*Irrigation*Day 
                     / ddfm=satterth;
      Random Block;
      repeated Day / subject=EU type=&type r rcorr;
      lsmeans       Accession Day Irrigation 
                    Accession*Day Accession*Irrigation Irrigation*Day Accession*Irrigation*Day
                     / adjust=Tukey;
   store ABCXYZ / label='PLM: Getting Started';
run;

proc plm restore=ABCXYZ;
   lsmeans Accession*Irrigation / lines linestable;
   ods output LSMLines=LSMLines;
run;
/* end of program */

Koen

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 15 replies
  • 2596 views
  • 6 likes
  • 3 in conversation