%MACRO BLUE_SG_da (trait);
PROC MIXED DATA=WORK.bo cl=wald covtest;
CLASS ID BLOCK EVR ;
MODEL &TRAIT=ID/s;
Random EVR EVR*ID BLOCK(EVR);
LSMEANS ID;
ODS output lsmeans=BLUE_SG_&trait;
run;
quit;
%mend BLUE_SG_da;
%BLUE_SG_da (trait= DRYWT_PL);
%BLUE_SG_da (trait= PROP_DRY_WT);
run;
%macro data(trait=);
data BLUE_SG_&trait; set BLUE_SG_&trait; &trait=estimate; keep ID &trait;
run;
%mend data;
%data(trait=DRYWT_PL);
%data(trait=PROP_DRY_WT);
run;
data BLUE_SG_total; merge BLUE_SG_DRYWT_PL BLUE_SG_PROP_DRY_WT; by ID;
run;
I. have tried to generate ls means. with the above script
I am facing with the following error
The way to debug code like this is to isolate the code that is giving the problem and remove it from the macro, if possible. Your code seems to work on the following simulated data, so perhaps there is something unusual about your data? Run the PROC MIXED against your actual data and examine the log.
%let trait=DRYWT_PL;
data bo_fake;
call streaminit(1);
do n = 1 to 20;
do ID = 0 to 1;
do block=0 to 2;
do evr=0 to 1;
&trait = id + evr + 2*evr*ID - 3*block*evr + rand("Normal");
output;
end;
end;
end;
end;
run;
ods trace on;
PROC MIXED DATA=WORK.bo_FAKE cl=wald covtest;
CLASS ID BLOCK EVR ;
MODEL &TRAIT=ID/s;
Random EVR EVR*ID BLOCK(EVR);
LSMEANS ID;
ODS output lsmeans=BLUE_SG_trait;
run;
If Kathleen is correct, then note that you can add ConvergenceStatus=<data set name> to the ODS output statement, and then read the variable called 'status' to determine if the model has failed to converge (a non-zero value indicates failure).
@IanWakeling you were right have tries to do as below script
PROC MIXED DATA=WORK.MBG cl=wald covtest;
CLASS ID BLOCK EVR ;
MODEL dw=ID/s;
Random EVR EVR*ID BLOCK(EVR);
LSMEANS ID;
ODS output ConvergenceStatus=BLUE_SG_dw;
run;
quit;
proc print data=BLUE_SG_dw;
id status;
run;
i have found with error 1 in status that means convergence not met the criteria so it did not converge,
May i know which model is better fit to my data to calculate the lsmeans
Thanks
@IanWakeling please find the results
Looking at the ouput posted I wonder if you are modelling the correct data? Mixed is saying that the class variable EVR has the value '1' for all observations - surely that is not what you intend?
Regarding my earlier comment - the output from Mixed will always tell you about the convergence status of you model, my point is that when writing a macro that uses this proc it is always a good idea to get the macro to programmatically check the convergence status of the model. You could do this by writing the value of 'status' to a macro variable and then making any further analysis contingent on the value being zero.
Hi @Rick_SAS thanks for your response, i have tries without macros (trait by trait) it works for few traits and i am facing errors for some traits. for instance the Lsmeans for dry weight is generated but convergence is not met for Plant height. i have also wrote the script as ConvergenceStatus=work.mbg i have attached you the results of two analysis
Thanks in advance
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.