BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CarolineW
Calcite | Level 5

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.

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_npar1way_a00...

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

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

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

View solution in original post

2 REPLIES 2
SteveDenham
Jade | Level 19

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

CarolineW
Calcite | Level 5

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.

http://support.sas.com/documentation/cdl/en/statug/67523/HTML/default/viewer.htm#statug_npar1way_det...

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1446 views
  • 0 likes
  • 2 in conversation