SUM ONE VARIABLE
%MACRO summ_prg (data=, out=); proc summary nway missing data=&data ; class year program level1 level2; id progname faculty category ; var value; output out=&out(drop=_freq_ _type_) sum(value)=; run; %mend summ_prg;
SUM MULTIPLE VARIABLES
%MACRO summ_prg (data=, out=); proc summary nway missing data=&data ; class year program level1 level2; id progname faculty category ; var value1 value2 value3; output out=&out(drop=_freq_ _type_) sum(value1 value2)=; run; %mend summ_prg;
To sum all the numerica variables, use var
_numeric_
and sum=.
CONDITIONAL SUM VARIABLES
%MACRO summ_prg (data=, out=); proc summary nway missing data=&data (WHERE = (CON_VAR = "XXX ")) ; class year program level1 level2; id progname faculty category ; var value1 value2 value3; output out=&out(drop=_freq_ _type_) sum(value1 value2)=; run; %mend summ_prg;
OUTPUT DESCRIPTIVE STATISTICS
%MACRO summ_prg (data=, out=); proc summary nway missing data=&data ; class year program level1 level2; id progname faculty category ; var value; output out=&out(drop=_freq_ _type_) n(value) = N mean(value)=mean q1(value)=q1 q3(value) =q3; run; %mend summ_prg;