%macro GlobTest(dataset,group,ngroups,varlist,test); /* Inputs: DATASET = Data set to be analyzed GROUP = Name of the group variable in the data set NGROUPS = Number of groups in the data set VARLIST = List of variable names corresponding to multiple endpoints TEST = OLS, GLS, MGLS or RS, for OLS test, GLS test, modified GLS test or rank-sum test, respectively */ %if &test="RS" %then %do; proc rank data=&dataset out=ranks; var &varlist; data comp; set ranks; array endp{*} &varlist; comp=0; do i=1 to dim(endp); comp=comp+endp{i}; end; proc mixed data=comp; class &group; model comp=&group; ods output tests3=pval; data pval; set pval; format fvalue 5.2 ndf 3.0 ddf 3.0 adjp 6.4; ndf=numdf; ddf=dendf; adjp=probf; label fvalue="F-value" adjp="Global p-value"; keep ndf ddf fvalue adjp; %end; %else %do; %let m=1; %let word=%scan(&varlist,&m); %do %while (&word ne); %let m=%eval(&m+1); %let word=%scan(&varlist,&m); %end; %let m=%eval(&m-1); data stand; %do i=1 %to &m; %let var=%scan(&varlist,&i); proc glm data=&dataset; class &group; model &var=&group; ods output FitStatistics=est(keep=rootmse depmean); data stand; set stand est; %end; data stand; set stand; if rootmse^=.; data _null_; set &dataset nobs=m; call symput("n",trim(put(m,5.0))); proc corr data=&dataset outp=corr(where=(_type_="CORR")) noprint; var &varlist; proc iml; use &dataset var{&varlist}; read all into data; use stand var{depmean}; read all into mean; meanmat=j(nrow(data),ncol(data),1)*diag(mean); use stand var{rootmse}; read all into pooledsd; sdmat=inv(diag(pooledsd)); use corr var{&varlist}; read all into r; stand=(data-meanmat)*sdmat; rinv=inv(r); if &test="OLS" then comp=stand*j(&m,1); if &test="GLS" then comp=stand*rinv*j(&m,1); if &test="MGLS" then comp=stand*sqrt(diag(rinv))*j(&m,1); create comp from comp; append from comp; data comp; merge comp &dataset; comp=col1; drop col1; proc mixed data=comp; class &group; model comp=&group; ods output tests3=pval; data pval; set pval; format fvalue 5.2 ndf 3.0 ddf 3.0 adjp 6.4; ndf=&ngroups-1; ddf=&n-&m*&ngroups; adjp=1-probf(fvalue,ndf,ddf); label fvalue="F-value" adjp="Global p-value"; keep ndf ddf fvalue adjp; %end; proc print data=pval noobs label; run; %mend GlobTest;