<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: KS statistic using Proc npar1way in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811514#M320100</link>
    <description>&lt;P&gt;PROC UNIVARIATE performs a one-sample KS test. This is the test that I have blogged about.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC NPAR1WAY performs a two-sample test. The Wikipedia article for a two-sample test uses the max distance between the two ECDFs to define the KS statistic. However, &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_npar1way_details24.htm" target="_self"&gt;the doc for NPAR1WAY&lt;/A&gt;&amp;nbsp;gives a formula (for k-samples) that depends on the differences between the ECDFs and the pooled ECDF.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 May 2022 17:07:44 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-05-04T17:07:44Z</dc:date>
    <item>
      <title>KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811439#M320052</link>
      <description>&lt;P&gt;hi, i have spent some time searching on Google to see how i can manually estimate the KS for two samples and then i estimated them using Excel and compared the results with proc npar1way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below are the results for the same data :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;manual KS : 0.059424551&amp;nbsp;&lt;/P&gt;
&lt;P&gt;npar1way : 0.066667 (D =0.133333)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't find why the outcome is not the same ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the attached excel is the raw data and the manual estimation (calculations can be found in cells)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, in the SAS tab i have provided the data as i use them in SAS to run the npar1way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ods graphics on;
proc npar1way edf plots=edfplot data=final;
class source;
var application_score;
output out=stat edf;
/*exact ks;*/
run;
ods graphics off;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 13:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811439#M320052</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-05-04T13:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811445#M320056</link>
      <description>&lt;P&gt;I don't know what to think of any calculations you did in Excel.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess the real question here is why don't you trust SAS in this case? The people at SAS spend a lot of time verifying that their calculations are correct. What is your concern, why do you need to verify "manually"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you use the code from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;to do this calculation in PROC IML? Did you plot the data to see if the SAS results makes sense from the plot?&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 13:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811445#M320056</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-04T13:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811450#M320061</link>
      <description>Valid point! i am not sure that i understand how npar1way estimates KS. I mean i don't know if there are any assumptions which are taken in background of the npar1way which affect the results.  &lt;BR /&gt;&lt;BR /&gt;I have seen the formulas in SAS guide but look complex and very time consuming. I have also seen posts from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; but i could not translate them into my problem. &lt;BR /&gt;&lt;BR /&gt;I have a population of data from which i take a sample from this population. I use KS to understand if the sample from this population is different. This is the question i am trying to answer here</description>
      <pubDate>Wed, 04 May 2022 13:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811450#M320061</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-05-04T13:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811453#M320063</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I have a population of data from which i take a sample from this population. I use KS to understand if the sample from this population is different. This is the question i am trying to answer here&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Do you mean a random sample, or some other type of sample? If random,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I'm sure the sample differs in some small way from the population. What I am struggling with is why this is even a question at all. From a statistical point of view, I can't recall seeing an example (or a reason) to test if a random sample differs from the entire population.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;i am not sure that i understand how npar1way estimates KS. I mean i don't know if there are any assumptions which are taken in background of the npar1way which affect the results.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Explain this. Why don't you understand? What about it don't you understand? Is it that you don't understand KS (which is a different question than what SAS is doing)? I don't think SAS builds in any assumptions that are not in the definition of a KS test.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Again, did you plot the data and take a look at the graphics? Does the KS calculations make sense from what you can see in the plot? If it doesn't make sense, show us and explain.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 14:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811453#M320063</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-04T14:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811484#M320081</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&lt;SPAN&gt;Do you mean a random sample, or some other type of sample? If random,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I'm sure the sample differs in some small way from the population. What I am struggling with is why this is even a question at all. From a statistical point of view, I can't recall seeing an example (or a reason) to test if a random sample differs from the entire population.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, this is a random sampling using Proc Survey. We expect the sample to be some how different from the population but not completely because it will lose some of the characteristics of the population&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&lt;SPAN&gt;Explain this. Why don't you understand? What about it don't you understand? Is it that you don't understand KS (which is a different question than what SAS is doing)? I don't think SAS builds in any assumptions that are not in the definition of a KS test.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I mean what are the calculations behind the npar1way since for many functions there are alternative ways to do the same thing. For example, in some functions i have seen they use only continuous variables&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Again, did you plot the data and take a look at the graphics? Does the KS calculations make sense from what you can see in the plot? If it doesn't make sense, show us and explain.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV align="center"&gt;
&lt;DIV id="tinyMceEditorToni2_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 04 May 2022 15:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811484#M320081</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-05-04T15:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811487#M320082</link>
      <description>I tried twice to edit my comment and add plots but i could not do. So the plot from SAS makes sense to describe KS the Excel graph looks a bit different but the trend is the same. I am not sure if this is because of the scale or selected the wrong graph</description>
      <pubDate>Wed, 04 May 2022 15:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811487#M320082</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-05-04T15:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811488#M320083</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/372747"&gt;@Toni2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&lt;SPAN&gt;Do you mean a random sample, or some other type of sample? If random,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I'm sure the sample differs in some small way from the population. What I am struggling with is why this is even a question at all. From a statistical point of view, I can't recall seeing an example (or a reason) to test if a random sample differs from the entire population.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, this is a random sampling using Proc Survey. We expect the sample to be some how different from the population but not completely because it will lose some of the characteristics of the population&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why? What do you hope to learn?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I mean what are the calculations behind the npar1way since for many functions there are alternative ways to do the same thing. For example, in some functions i have seen they use only continuous variables&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is your question really "what are the calculation of the KS Test"? I don't think SAS is doing anything other than the standard calculations for KS test here, which you can learn more about at &lt;A href="https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test" target="_self"&gt;Wikipedia&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 15:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811488#M320083</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-04T15:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811514#M320100</link>
      <description>&lt;P&gt;PROC UNIVARIATE performs a one-sample KS test. This is the test that I have blogged about.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC NPAR1WAY performs a two-sample test. The Wikipedia article for a two-sample test uses the max distance between the two ECDFs to define the KS statistic. However, &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_npar1way_details24.htm" target="_self"&gt;the doc for NPAR1WAY&lt;/A&gt;&amp;nbsp;gives a formula (for k-samples) that depends on the differences between the ECDFs and the pooled ECDF.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 17:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811514#M320100</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-05-04T17:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811546#M320116</link>
      <description>&lt;P&gt;Thanks for your response here. I have three questions for the npar1way if you can advise please&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) Does the above different approaches lead to different KS?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Could we use npar1way with any numeric variable (continuous, discrete etc.)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) Could we use npar1way for character variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 19:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811546#M320116</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-05-04T19:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811547#M320117</link>
      <description>&lt;P&gt;thanks for your support &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your points are very helpful since it seems sometimes we do things without thinking!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 20:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811547#M320117</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-05-04T20:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811550#M320118</link>
      <description>&lt;P&gt;1) Possibly yes, but I haven't worked through the math.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) The KS (and all ECDF tests) are for numeric continuous variables. The CLASS variable can (and should) be discrete.&lt;/P&gt;
&lt;P&gt;3) No, see (2).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bonus: Here is a &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_npar1way_overview.htm" target="_self"&gt;link to the NPAR1WAY doc.&amp;nbsp;&lt;/A&gt;&amp;nbsp;The Overview and Getting Started sections describe the capabilities of the procedure.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 20:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811550#M320118</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-05-04T20:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811554#M320122</link>
      <description>thank you again, this is really useful!</description>
      <pubDate>Wed, 04 May 2022 20:19:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811554#M320122</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-05-04T20:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811628#M320147</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/372747"&gt;@Toni2&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/372747"&gt;@Toni2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;manual KS : 0.059424551&amp;nbsp;&lt;/P&gt;
&lt;P&gt;npar1way : 0.066667 (D =0.133333)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't find why the outcome is not the same ?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To get back to your original question: Your "manual KS" uses cumulative &lt;EM&gt;sums&lt;/EM&gt; of scores (relative to overall &lt;EM&gt;totals&lt;/EM&gt; of scores), whereas the values of the empirical distribution function (EDF) are proportions of cumulative &lt;EM&gt;numbers&lt;/EM&gt; of scores, relative to the total &lt;EM&gt;number&lt;/EM&gt; of scores. So, in the calculation you need to &lt;EM&gt;count&lt;/EM&gt; scores (to find out &lt;EM&gt;how many&lt;/EM&gt; of them are less than or equal to some value), not to&amp;nbsp;&lt;EM&gt;add&lt;/EM&gt; scores. The cumulative percentages that you can obtain with PROC FREQ are basically values of the EDF &lt;EM&gt;in percent&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you trust the rightmost column "Cumulative Percent" of a basic PROC FREQ output? If so, you can use PROC FREQ to compute the EDFs "manually" and then apply the formula of the KS statistic from the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_npar1way_details24.htm" target="_blank" rel="noopener"&gt;PROC NPAR1WAY documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's how (using your dataset FINAL with variable &lt;FONT face="courier new,courier"&gt;application_score&lt;/FONT&gt; renamed to &lt;FONT face="courier new,courier"&gt;ascore&lt;/FONT&gt; for brevity)&lt;FONT face="helvetica"&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Store number of scores from 'pop' and 'smp' in macro variables n1, n2 */

proc sql noprint;
select count(ascore) into :n1 trimmed
from final(where=(source='pop'));
select count(ascore) into :n2 trimmed
from final(where=(source='smp'));
quit;

/* Compute EDF (in %) for SOURCE='pop' */

proc freq data=final noprint;
where source='pop';
tables ascore / outcum out=edf1(keep=ascore cum_pct rename=(cum_pct=f1));
run;

/* Compute EDF (in %) for SOURCE='smp' */

proc freq data=final noprint;
where source='smp';
tables ascore / outcum out=edf2(keep=ascore cum_pct rename=(cum_pct=f2));
run;

/* Compute pooled EDF (in %) */

proc freq data=final noprint;
tables ascore / outcum out=edf0(keep=ascore cum_pct rename=(cum_pct=f));
run;

/* Combine all three EDFs */

data edf_all;
merge edf0-edf2;
by ascore;
_=.;
run;

/* Fill missing values */

data edf(drop=_);
update edf_all(obs=0) edf_all;
by _;
output;
run;

/* Prepare computation of Kolmogorov-Smirnov statistic */

data edfks;
set edf;
s=sqrt((&amp;amp;n1*(sum(f1,-f))**2+&amp;amp;n2*(sum(f2,-f))**2)/(&amp;amp;n1+&amp;amp;n2));
run;

/* Compute Kolmogorov-Smirnov statistic */

proc sql;
select max(s)/100 as KS format=best16.
from edfks;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 May 2022 09:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811628#M320147</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-05-05T09:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811812#M320241</link>
      <description>&lt;P&gt;great! thanks. Quick questions since i have read a lot on Google.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to compare two samples to understand if there is significant difference between them. Do i need to use the KS or the D statistic in SAS since i am not sure that i can understand the differences?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 08:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811812#M320241</guid>
      <dc:creator>Toni2</dc:creator>
      <dc:date>2022-05-06T08:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: KS statistic using Proc npar1way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811825#M320248</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/372747"&gt;@Toni2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to compare two samples to understand if there is significant difference between them. Do i need to use the KS or the D statistic in SAS since i am not sure that i can understand the differences?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you want to perform a statistical &lt;EM&gt;test&lt;/EM&gt;. The p-value of the asymptotic Kolmogorov-Smirnov two-sample test in the default output of PROC NPAR1WAY is denoted as "Pr &amp;gt; KSa", so apparently refers to the asymptotic&amp;nbsp;Kolmogorov-Smirnov statistic KSa (=KS*sqrt(n)). When you specify the &lt;A href="https://documentation.sas.com/doc/en/statug/15.2/statug_npar1way_syntax01.htm#statug.npar1way.np1d" target="_blank" rel="noopener"&gt;D option&lt;/A&gt; of the PROC NPAR1WAY statement, the output contains a p-value "Pr &amp;gt; D" &lt;EM&gt;instead&lt;/EM&gt; (referring to the D statistic), which was &lt;EM&gt;identical&lt;/EM&gt; with "Pr &amp;gt; KSa" (in the case of two samples) in all test cases that I've run. The documentation describes the p-value in terms of the D statistic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you have only two samples ("class levels"), so D is applicable, and the definition of D is simpler, I would use the D statistic (also in view of the equality of p-values mentioned above).&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 09:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/KS-statistic-using-Proc-npar1way/m-p/811825#M320248</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-05-06T09:59:00Z</dc:date>
    </item>
  </channel>
</rss>

