SAS/Math Functions

< SAS

Probabilistic Functions

edit

SAS includes a set of probabilistic functions. Instead of reading quantile tables, one can print the quantiles of a variable in the SAS log.

data _null_;
    q975 = probit(.975);
	q025 = probit(.025);
	q95 = probit(.95) ; 
	q05 = probit(.05) ; 
    put q975 = ;
	put q025= ;
	put q95 = ; 
	put q05 = ; 
run;

Note that we use a data step but we do not create any table. We also use the 'put' instruction to print the result in the log. Alternatively one can also use the PROC IML and print the results in the output window :

proc iml ; 
q975 = probit(.975) ; 
print q975  ; 
quit ;

For a Student distribution, the first number is the quantile and the second the number of degrees of freedom.

data _null_ ; 
q975 = tinv(.975,10);
q025 = tinv(.025,10);
put q975 = ; 
put q025 = ; 
run ;

For a   distribution :

data _null_;
    q95 = cinv(0.95,5);
    put q95 = ;
run;

For a Fisher distribution :

data _null_;
    q95 = finv(0.95,5,5);
    put q95 = ;
run;
Distribution CDF Quantile PDF Random Deviates
Beta probbeta(p, , ) betainv(q, , ) _
  probchi(p,n) cinv(q,n) _
Fisher probf(p,d1,d2) finv(q,d1,d2)
Gaussian probnorm(p) probit(q) rannor(0)
Student probt(p,n) tinv(q,n)
Uniform ranuni(0)

Statistical Functions

edit
  • mean()
  • N
  • Nmiss

Maths Functions

edit
  • log