BookmarkSubscribeRSS Feed
maivu
Calcite | Level 5

I have to write a SAS macro in terms of the Kolmogorov Smirnov statistic. I spent a lot of time to do it but haven't finished so who can help me please? The question is:

Write a SAS macro which has 3 parameters: m for the number of simulation iterations, n for the sample size, and @ for the upper tail probability. given values of the 3 parameters, it returns a simulation-based estimate of the (1-@) quantile of the sampling distribution of the Kolmogorov-Smirnov statistic for data from the standard normal distribution. 

%D(m=500, n=5, @=0.10);

%D(m=1000, n=10, @=0.05);

 

2 REPLIES 2
Reeza
Super User

Post what you've tried. And this is clearly homework. 

Rick_SAS
SAS Super FREQ

I suggest you begin with 

%let m=500;

%let n=5;

%let alpha=0.10;

then write a DATA step that generates m samples, each of size n.

Run PROC UNIVARIATE with BY-group processing on the Sample ID variable.

Then analyze the empirical frequency of the indicator variable ( KS > alpha ).

For hints and similar Monte Carlo estimates, see

"Using simulation to estimate the power of a statistical test"

which uses PROC TTEST (on two independent samples) instead of the KS (on one sample).

 

After everything is debugged and working, it is trivial to wrap the code into a macro.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1275 views
  • 0 likes
  • 3 in conversation