BookmarkSubscribeRSS Feed
VioletaB
Calcite | Level 5

Hello!

 

I want to calculate sample size per group (or total) for difference in Median. So i have information what diff in median i expect (effect) and estimated SD, want 90% power and alpha=0.05. How can i calculate sample size in SAS for this?

 

Thank you 

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hello @VioletaB,

 

If you have two independent samples with a location shift between their (otherwise ideally equal) distributions, I would suggest the TWOSAMPLEWILCOXON statement of PROC POWER. Note, however, that the expected median difference and estimated standard deviation (together with power and significance level) do not provide sufficient information for the sample size calculation. Sample size for the Wilcoxon rank-sum test also depends on the shape of the distribution. This is why there is the VARDIST option where you need to specify the distributions of the two samples.

 

Example: Normal distributions with SD=1.2, shifted by |m1m2|=1

proc power;
twosamplewilcoxon
vardist('Group 1')=normal(0, 1.2)
vardist('Group 2')=normal(1, 1.2)
variables = 'Group 1' | 'Group 2'
sides = 2
alpha = 0.05
power = 0.85
npergroup = .;
run;

Result: n=28 per group.

 

With the more heavy-tailed Laplace distribution

vardist('Group 1')=laplace(0, 0.848528)
vardist('Group 2')=laplace(1, 0.848528)

the result is only n=21 per group, although the median difference and standard deviation (sqrt(2)*0.848528...=1.2) are the same as for the normal distributions above.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 740 views
  • 2 likes
  • 2 in conversation