Programming the statistical procedures from SAS

View implementation of the NPAR1WAY procedure

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

View implementation of the NPAR1WAY procedure

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


Accepted Solutions
Solution
‎02-27-2015 11:34 AM
Respected Advisor
Posts: 2,655

Re: View implementation of the NPAR1WAY procedure

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


All Replies
Solution
‎02-27-2015 11:34 AM
Respected Advisor
Posts: 2,655

Re: View implementation of the NPAR1WAY procedure

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

New Contributor
Posts: 2

Re: View implementation of the NPAR1WAY procedure

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 332 views
  • 0 likes
  • 2 in conversation