So my question is very similar to this one https://communities.sas.com/t5/Base-SAS-Programming/Proc-Means-loop-Macro/m-p/177460/highlight/true#M33928 However, I want to try to add in any interaction effects. I'm trying to add flexibility into my code. Originally when I wrote this, my code would only allow me 2 Factors with 2 sublevels each. I will try to keep it simple because once I get the main idea I can probably apply it to what else I want to do in my code. Essentially I want it so my code can read in any number of "Factors" and "levels" of the said Factors: Example: Factor1(has categorical responses, such as Yes, No), Factor2(same thing, cat responses), I don't want to limit the responses to only 2 though. Let's focus on the proc means part first, I may ask a seperate question for what I want to do next. So essentially I have this....
%MACRO meansANOVA (data, totalvars, Factor1, Factor2, S1F1, S1F2, S2F1, S2F2)
%DO i = 1 %TO &totalvars;
proc means data = &data clm mean std stderr;
class &Factor1 &Factor2;
var m&i;
ods output summary= &data.Means&i;
run;
proc means data = &data clm mean std stderr;
class &Factor1;
var m&i;
ods output summary= &data.&Factor1.Means&i;
run;
proc means data = &data clm mean std stderr;
class &Factor2;
var m&i;
ods output summary= &data.&Factor2.Means&i;
run;
What I want to do is to somehow do this automatically. Some way to create a means data(I need them seperately) of each individual factor + their possible interaction effects. So if I had 3 factors for example it would run proc means on factor 1, factor 2, and factor 3, and then run it on factor1*factor2, factor1*factor3, factor2*factor3 and factor1*factor2*factor3 and generate seperate outputs. Does anyone have an idea of how I can do this? I was thinking there would be use of the scan function.
Originally when I ran this analysis I did all the merging/seperating/etc..(data manipulation) through JMP, I was trying to write a Macro that may automate everything I did.
TLDR: My major goal is to just "automate" tons of data manipulation through SAS probably through a macro so that all I would need to put in is a few things such as dataset name, total # of variables we're interested in, and possible factors/levels of said factors each time.
Like I said, currently I have my code written out so that it would take in 2 Factors with 2 sublevels. so Factor 1, Yes/No, and Factor 2, Yes/No for example. My code IS working but it's very messy and has tons of lines of code ~500+ lines of code. I want to give it more flexibility so that my input data does not need to be 2 Factors with 2 sublevels and perhaps could do 2 Factors with 3 sublevels or 3 Factors with 3 sublevels, etc....
Edit: "Inputdata.xlsx" is a small sample of what my input data looks like, I deleted all the variables that I wasn't interested in and also changed/edited some of the names. It has 2 factors to make it "Easier." "Example.xlsx" shows what my final "means" table should look like for a different project that had 3 factors instead of 2. "Example1.xlsx" shows the means table before I start separating it and merging with other tables for my Inputdata.
... View more