Hi everyone I have a specific question regarding my anova I have created. I have to create 4 anova results, and when I run my code it creates anovaresults2, anovaresults3 and anovaresults4, I do not know why my anovaresults 1 does not show up as I have set each anova up the same way. My code is below please let me know what you think is going wrong, THANK YOU!
Please read the log from this code and see if there are ERROR or WARNING or NOTE that explains this.
If that doesn't get you the answer, then please add
options mprint;
as the first line of your program, run the whole thing, and then you look at the log, with the extra information and see if an ERROR or WARNING or NOTE indicates what the problem is.
As a last resort, if none of the above seems to indicate the problem, show us the log by performing the following steps:
As a matter of general principles, always put the ODS OUTPUT statements after the PROC statements.
FYI - if you search on here you'll find a method I suggested that accomplishes everything you're trying to do WITHOUT macros and significantly less code. One of your classmates already asked this question.
As to why it's not running, as others have indicated you'll need to provide the log - it usually has the errors and reasons why. If it works for one set of variables and not another it's likely something specific with that piece of code or variable, that we can't answer without the data. You can also try it with a known data set that's similar such as sashelp.heart.
@Rohan_Garg4 wrote:
Hi everyone I have a specific question regarding my anova I have created. I have to create 4 anova results, and when I run my code it creates anovaresults2, anovaresults3 and anovaresults4, I do not know why my anovaresults 1 does not show up as I have set each anova up the same way. My code is below please let me know what you think is going wrong, THANK YOU!
ODS OUTPUT ModelANOVA = WORK.ModelResults1;PROC ANOVADATA = MIInq.MIIInquiry2;CLASS StateCd;Model AgeAtVisit = StateCd;RUN;%MACRO RunANOVA (Number = , Variable = );ODS OUTPUT ModelANOVA = MIOut.ANOVAResults&Number;PROC ANOVADATA = MIInq.MIInquiry2;CLASS StateCd;MODEL &Variable = StateCd;RUN;QUIT;PROC PRINT DATA = MIOut.ANOVAResults&Number;RUN;%MEND RunANOVA;%RunANOVA (Number = 1, Variable = AgeAtVisit)%RunANOVA (Number = 2, Variable = SBP)%RunANOVA (Number = 3, Variable = DBP)%RunANOVA (Number = 4, Variable = WtLb);PROC MEANS DATA = MIInq.MIInquiry2;CLASS StateCd;VAR WtLb;RUN;DATA MIOut.ANOVAResults (KEEP = Dependent FValue ProbF);SET WORK.ANOVAResults: ;RUN;
Yep, @Reeza is correct, you don't need macros here at all, which probably simplifies the code greatly. https://communities.sas.com/t5/SAS-Programming/Using-Macro-Variables-With-Proc-Anova/m-p/703459#M215...
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.