%macro Probt(_t, _df, _RetProbt); /**************************************************************************************/ /* Name: ProbT.sas Auth: Phil Rack */ /* Date: 5/16/2007 Revd: */ /* */ /* Desc: Calculates the right-tail values for points on a t-distribution curve. */ /* */ /* Where: _t = is the t-value you want to test. */ /* _df = is the degrees of freedom. */ /* _retProbt = The calculated Probt (the returned value.) */ /* */ /* Copyright (C) 2007 by MineQuest, LLC. All Rights Reserved. www.minequest.com */ /**************************************************************************************/ IF (%length(%str(&_t)) eq 0) or (&_t = '.') OR (%length(%str(&_df)) eq 0) or (&_df = '.') THEN DO; &_RetProbt = .; END; Else DO; _ptx = 1; _pty = 1; _ptt = &_t**2; IF _ptt GE 1 THEN DO; _pts = _pty; _ptr = &_df; _ptz = _ptt; END; IF _ptt < 1 THEN DO; _pts = &_df; _ptr = _pty; _ptz = 1 / _ptt; END; _ptj = 2 / 9 / _pts; _ptk = 2 / 9 / _ptr; *--> Compute using approximation formula; _ptl = ABS(( 1 - _ptk) * _ptz ** (1/3) - 1 + _ptj) / SQRT(_ptk * _ptz**(2/3) + _ptj); IF _ptr GE 4 THEN DO; _ptx = .5 / (1 + _ptL * (.196854 + _ptL * (.115194 + _ptL * (.000344 + _ptL * .019527)))) ** 4; _ptx = INT(_ptx* 1000000 + .5) / 1000000; IF _ptt > = 1 THEN &_RetProbt = _ptx; ELSE &_RetProbt = 1 - _ptx; END; IF _ptr LT 4 THEN DO; _ptl = _ptl * (1 + .08* _ptl**4 / _ptr ** 3); _ptx = .5 / (1 + _ptL * (.196854 + _ptL * (.115194 + _ptL * (.000344+ _ptL * .019527)))) ** 4; _ptx = INT( _ptx * 1000000 + .5) / 1000000; IF _ptt > = 1 then &_RetProbt = _ptx; ELSE &_RetProbt = 1 - _ptx; END; DROP _ptr _ptx _pty _ptt _pts _ptz _ptj _ptk _ptl; END; /*****************************************************************************************/ /* ProbT is copyright (c) 2007 by MineQuest, LLC. All Rights Reserved. */ /* MineQuest, LLC, 1939 Queensbridge Dr., Columbus, OH USA. */ /* This Macro Program is proprietary software and is licensed property of MineQuest, LLC. */ /******************************************************************************************/ %mend Probt;