Search code examples
sasgaussianquantile

Quantile transformation with SAS using z-scores?


Given is a value quantile_x (say 42 Euro) which corresponds to the x-quantile (say 99%) of a (non-normalized) Gaussian distribution. I am now interested of the value quantile_y corresponding to the y-quantile (say 95%).

I would love to simply write

proc sql;
   create table want as
   select quantile_x
         ,%transform(quantile_x,x,y) as quantile_y
   from have;
quit;

For the given example, %transform() should actually simply perform the following product

quantile_y = quantile_x * 1.645 / 2.326

The numbers are the z-scores for 97% quantile and the 99% quantile, respectively. Somehow, I failed to figure out, how I can obtain these two numbers using SAS.

Edit: Reading SAS docu on probnorm it looks like I am after its inverse function since probnorm(1.96)=0.9750021049.

References


Solution

  • Use the quantile() function.

    data have;
      input x y actual;
      z_x = quantile('NORMAL',x);
      z_y = quantile('NORMAL',y);
      adjusted = actual * z_y / z_x;
    cards;
     .99 .95 2.32635
     .99 .95 42
    ;
    

    Results:

    Obs      x       y      actual      z_x        z_y      adjusted
    
     1     0.99    0.95     2.3264    2.32635    1.64485      1.6449
     2     0.99    0.95    42.0000    2.32635    1.64485     29.6963