BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Does anyone know how to do a Kruskal Wallis test in SAS with TWO independent variables instead of just one?
4 REPLIES 4
Olivier
Pyrite | Level 9
I haven't checked what test KW is exactly, but from what I remember, it is like an analysis of variance on ranks, isn't it ?
If so, just compute ranks with PROC RANK and then proceed with PROC GLM.
Am I correct ?
deleted_user
Not applicable
Thanks. Yes, it is based on rank as far as I can tell. It seems to be a nonparametric equivalent of ANOVA and you can use proc npar1way, but now I want to add a second independent variable. It doesn't seem to allow this and the only thing I could find when I googled it was some talk of macros that created a multivariate KW, but couldn't actually get to the macro itself.
LAP
Quartz | Level 8 LAP
Quartz | Level 8
You can use proc npar1way to do a Kruskal-Wallis (Wilcoxen)


From Documentation....
The Nonparametric One-Way ANOVA task enables you to perform nonparametric tests for location and scale when you have a continuous dependent variable and a single independent classification variable. You can perform a nonparametric one-way ANOVA using Wilcoxon (Kruskal-Wallis), median, Van der Waerden,.....
Doc_Duke
Rhodochrosite | Level 12
Just rank the dependent variable and then run the two way ANOVA via GLM.

Generally, you can do any rank-based analysis using the normal theory equivalent procedure in SAS. However, you are relying on the Central Limit Theorem to get the p-values, so you may need substantial sample sizes for this to work. [That's what Wilcoxon was doing when he developed the Rank-Sum test; he was looking for an easier way to do a t-test (think hand calculation!).]

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3378 views
  • 0 likes
  • 4 in conversation