You can find a closed-form matrix method to evaluate the Kolmogorov distribution in Marsaglia et al (2003) and an improved algorithm in Carvalho (2015). This method writes the CDF of the Kolmogorov distribution as an element from the power of a matrix with finite dimensions, so it allows exact computation. To facilitate the analysis, suppose we write the argument value of interest in the CDF as:
$$d = \frac{k-\theta}{n},$$
where $k$ is a positive integer and $0 \leqslant \theta < 1$ is a remainder. Let $m \equiv 2k+1$ and define $\mathbf{H}(\theta)$ to be an $m \times m$ matrix of the form:
$$\mathbf{H}(\theta) \equiv \begin{bmatrix}
\tfrac{(1-\theta)}{1!} & 1 & 0 & 0 & 0 & \cdots & 0 & 0 \\
\tfrac{(1-\theta^2)}{2!} & \tfrac{1}{1!} & 1 & 0 & 0 & \cdots & 0 & 0 \\
\tfrac{(1-\theta^3)}{3!} & \tfrac{1}{2!} & \tfrac{1}{1!} & 1 & 0 & \cdots & 0 & 0 \\
\tfrac{(1-\theta^4)}{4!} & \tfrac{1}{3!} & \tfrac{1}{2!} & \tfrac{1}{1!} & 1 & \cdots & 0 & 0 \\
\tfrac{(1-\theta^5)}{5!} & \tfrac{1}{4!} & \tfrac{1}{3!} & \tfrac{1}{2!} & \tfrac{1}{1!} & \cdots & 0 & 0 \\
\vdots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
\tfrac{(1-\theta^{m-1})}{(m-1)!} & \tfrac{1}{(m-2)!} & \tfrac{1}{(m-3)!} & \tfrac{1}{(m-4)!} & \tfrac{1}{(m-5)!} & \cdots & \tfrac{1}{1!} & 1 \\
\tfrac{(1-\theta^{m})}{m!} & \tfrac{(1-\theta^{m-1})}{(m-1)!} & \tfrac{(1-\theta^{m-2})}{(m-2)!} & \tfrac{(1-\theta^{m-3})}{(m-3)!} & \tfrac{(1-\theta^{m-4})}{(m-4)!} & \cdots & \tfrac{(1-\theta^2)}{2!} & \tfrac{(1-\theta)}{1!} \\
\end{bmatrix}.$$
Then, for a Kolmogorov-Smirnov test with $n$ data points yielding the statistic $D_n$, the cumulative distribution of interest (under the null hypothesis) can be written in matrix form as:
$$F_n(d) \equiv \mathbb{P}(D_n \leqslant d) = \mathbb{P} \bigg( D_n \leqslant \frac{k-\theta}{n} \bigg) = \frac{n!}{n^n} \cdot [\mathbf{H}(\theta)^n]_{k,k}.$$
This formula allows us to compute the CDF of the Kolmogorov distribution by computing an element of a finite power of a finite matrix. It therefore gives an exact closed-form method that operates without any truncation or other approximation. The method is implemented in R in the kolmim package (documentation here).
Hint: SAS has multiple options on how to run this procedure, so you'll need more than just a screenshot of the test statistic and final $p$-value for any real hope at understanding how it's computed. You'll need source code too.
– StatsStudent Jan 25 '19 at 01:06