Fluorite | Level 6

## Using interaction statement in Macro

Please I have my data in excel and I am using macro statements as shown below. I have my macros to analyze YieldB, YieldC and YieldW (which is working fine). Now I will like to see if there is an interaction between each of these yields and other variables that I have in the excel sheet.

For instance how do I have an interaction statement like YieldB X MeanT and where exactly should it be in the code

My code is below:

proc print;
proc sort data=C_YieldM;
by Trial;

/* Running Factorial Design without Rep effect but with day effect, The Covtest provides the covariance parameter estimates*/
%macro Rotation (var=);
proc mixed data=C_YieldM;
*By Year;
class Rep Trial T_System;
model &var=T_System;
random Rep(Trial) Trial Trial*T_System/solution;
repeated Trial/subject=rep*T_System type=ar(1) RCORR;
Lsmeans T_System/diff=all;

/* Contrasts statement for the management practice */
estimate 'IRR_RF' T_System 1 -1;
ods output diffs=table;
ods output lsmeans=Mylsmeans;
Store Mylsmeans;

data calc_lsd;
set table;
lsd=stderr*tinv(1 -(0.05/2), df);
run;

proc print data=calc_lsd;
*var lsd estimate stderr df;
run;

proc plm restore=Mylsmeans;
run;

%mend Rotation;

%Rotation (var=YieldB);
%Rotation (var=YieldC);
%Rotation (var=YieldW);

run;

3 REPLIES 3
Super User

## Re: Using interaction statement in Macro

Looks to me like you are using PROC MIXED.

So look at the manual for PROC MIXED.

Once you understand what code you want to run THEN you can think about to use a macro to generate that code.

Fluorite | Level 6

## Re: Using interaction statement in Macro

Thanks Tom. I can do the interaction if I used card input, but I have been using macro (with my data in excel) but where to fit in my interaction statement is my concern. Thanks you

Super User

## Re: Using interaction statement in Macro

@Olanike wrote:

Thanks Tom. I can do the interaction if I used card input, but I have been using macro (with my data in excel) but where to fit in my interaction statement is my concern. Thanks you

That makes no sense to me. A CARDS statement is something you would use in a DATA step. An interaction is something you would specify in some statistical proc.  How you read the data makes no difference once you already have the dataset and are running a PROC.

Discussion stats
• 3 replies
• 393 views
• 0 likes
• 2 in conversation