Hey!
I want to write a macro for ANOVAS that tests a number of dependent variables against one independent variable. My current version looks like this:
%MACRO anov(input_dataset= , independent_variable= , variable_list=, output_dataset= );
/* Check how man variables are in the list */
%LET M=%WORDS(&variable_list.);
%DO i=1 %TO &M.;
%LET var = %SCAN (&variable_list., &i.);
PROC ANOVA DATA= &input_dataset.;
CLASS &independent_variable.;
MODEL &var. = &independent_variable.;
MEANS &independent_variable.;
ODS OUTPUT Summary=output1 (RENAME=(&var._Mean = Mean &var._STDDEV=STDDEV));
PROC MEANS DATA = &input_dataset. Mean STDDEV;
VAR &var.;
class &independent_variable.;
RUN;
ods output close;
ODS OUTPUT means=anova modelAnova=model2;
PROC ANOVA DATA= &input_dataset.;
CLASS &independent_variable.;
MODEL &var. = &independent_variable.;
MEANS &independent_variable.;
RUN;
Quit;
ods output close;
%END;
%MEND anov;
%anov (input_dataset=multiple_sclerosis,
independent_variable= ms_form,
variable_list=eq5d hp_general_health)
Unfortunately, I'm fairly new to SAS and struggling a bit here. The variable ms_form can be 1, 2 or 3. I want my output to have the name of the variable in the first column (so eq5d for the first 3, then hp_general_health) followed by the group means, and the standard derivation, the f-statistics, and the p-value. Anybody knows what exactly I should do?
Thanks in advance!
Create a format and apply it to your source data. The format should flow through the rest of the program.
Here's a quick intro on creating formats
And format and comment your code. It's barely legible as posted.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.