Hello,
I have implemented a two-sample Kolmogorov-Smirnov test in a language other than SAS. However, I need to compare my results with a set of results originating from the NPAR1WAY procedure in SAS. I have installed the SAS University Edition, thinking that one could view the source code of a procedure by typing some command (similar to R and MATLAB), but I have not found how to do so.
The following documentation describes the theoretical equations for the KS-test in SAS.
However, I would like to see the exact implementation of these equations. The approximation of the p-value can differ a lot, and while I don't care about which one is the most correct, I need to know the SAS implementation of it.
It seems like SAS calculates the complementary distribution instead of the actual distribution. When I do this in my code, the result is way off, while if I remove the (1 -) to calculate the actual distribution, the result is more reasonable.
So, to the question, how can I see the actual implementation of the Kolmogorov-Smirnov test in SAS?
Thanks,
Caroline
Short answer: You cannot see the code.
Long answer: You cannot see the code because it is proprietary. However, you can see the methodology and any formulas via the link you supplied. Given the fairly long history of NPAR1WAY and its implementation, I would check to see if anyone else has written a macro using DATA step or IML code to calculate KS. The archives at lexjansen.com would be good starting place.
Steve Denham
Short answer: You cannot see the code.
Long answer: You cannot see the code because it is proprietary. However, you can see the methodology and any formulas via the link you supplied. Given the fairly long history of NPAR1WAY and its implementation, I would check to see if anyone else has written a macro using DATA step or IML code to calculate KS. The archives at lexjansen.com would be good starting place.
Steve Denham
Thank you for your answer!
I suspected that it could be something along those lines, but since MATLAB shares their code for built-in functions I thought that SAS might also have done so.
I am not very familiar with SAS and realized that I was looking at old documentation (I think). The documentation for SAS/STAT 9.22 (link provided in the first post) gives an incorrect equation for the procedure (or it could be that the text is just misleading). The equation was changed from this complimentary distribution to the actual distribution in the documentation for SAS/STAT 13.2. See link below.
I have also implemented this later version of the equation and get the exact same result as SAS, indicating that this is the actual formula implemented in the SAS procedure.
Once again, thank you very much for your answer. This saved me a lot of time googling for code that does not exist.
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 16. Read more here about why you should contribute and what is in it for you!
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.