* User Defined Model 노드를 통해 E-Miner의 모형화 노드를 통해 생성되지 않은 모형에 대해 그러한 모형의 결과를 불러들이고 Assessment노드를 통해 평가할수 있다. 외부 모형을 불러들이는 방법은 Input Data source 노드, SAS Code 노드와 Variable Selection 노드를 이용할수 있다. User Defined Model 노드는 모형평가를 위한 통계량을 계산하기 위해서는 분석용,평가용, 검증용 또는 원자료 중 적어도 하나의 자료가 필요하고 그러한 자료에는 목표(target)변수와 예측된(predicted) 값을 갖는 변수가 포함되어 있어야 한다.
| 1. MINER 프로그램 |
| 2. DMREG 모델 |
| 3. TREE 모델 |
| 4. USER Defined 모델 |
1. MINER 프로그램 |














2. DMREG 모델 | |
|
LIBNAME EMSAMPLE 'C:\work\데이터마이닝방법론예제데이터(강현철)'; LIBNAME EMDATA 'C:\work\'; LIBNAME EMPROJ 'C:\work\';
libname SAMPSIO list;
data EMDATA.VIEW_IXA / view=EMDATA.VIEW_IXA; set EMSAMPLE.BUYTEST; run;
data EMPROJ.SMP_VIV2(drop=_I3TMFA3); retain _I3TMFA3 0; set EMSAMPLE.BUYTEST; if ranuni(0) < (2000-_I3TMFA3) / (10000-_n_+1) then do; _I3TMFA3 = _I3TMFA3 + 1; output; end; run;
proc datasets library = EMPROJ nolist; modify SMP_VIV2(label = 'Sample of EMSAMPLE.BUYTEST'); quit;
%let _tmp=%DMNORLEN; proc dmdb data=EMDATA.VIEW_IXA out=_null_ dmdbcat=EMPROJ.dm_DGM00000 normlen=32 maxlevel=513; id ID; class RESPOND(Desc) SEX(Asc) MARRIED(Asc) OWNHOME(Asc) LOC(Asc) CLIMATE(Asc) BUY6(Asc) BUY12(Asc) BUY18(Asc) ORGSRC(Asc) DISCBUY(Asc) RETURN24(Asc) COA6(Asc); var AGE INCOME FICO VALUE24 C1 C2 C3 C4 C5 C6 C7 PURCHTOT; target RESPOND; run;
* Create data view with dmdb name; data EMDATA.dm_DGM00000 / view=EMDATA.dm_DGM00000; set EMDATA.VIEW_IXA; run;
data EMPROJ.RESPOND_(type=PROFIT label=RESPOND); LENGTH RESPOND $%DMNORLEN; input RESPOND $1-%DMNORLEN _MPRIOR _DEC1 @; label _DEC1="1"; cards; 1 0.0767 1 0 0.9233 0 ; run; quit;
data work._DECDBG_; set EMPROJ.RESPOND_; run; quit;
proc dmreg data = emdata.dm_DGM00000 dmdbcat= EMPROJ.dm_DGM00000 outest = EMPROJ.DMRGZNU0(label="DMREG Parameter Estimates for node T0R5N"); class RESPOND SEX MARRIED OWNHOME LOC CLIMATE BUY6 BUY12 BUY18 ORGSRC DISCBUY RETURN24 COA6; model RESPOND = AGE BUY12 BUY18 BUY6 C1 C2 C3 C4 C5 C6 C7 CLIMATE COA6 DISCBUY FICO INCOME LOC MARRIED ORGSRC OWNHOME PURCHTOT RETURN24 SEX VALUE24 / coding=DEVIATION error = BINOMIAL link=LOGIT nodesignprint; nloptions maxtime = 604800 absfconv = 0 1 absgconv = 0.00001 1 absxconv = 1E-8 1 fconv = 0 1 gconv = 1E-6 1; decision decisiondata = EMPROJ.RESPOND_ decvars = _DEC1; score data=EMDATA.VIEW_IXA out =EMPROJ._A000039(label="Assessment data set for TRAIN" keep=P_: D_: ID _WARN_ EP_: BP_: CP_: EL_: BL_: CL_: IC_: RESPOND); score data=EMDATA.VIEW_IXA out=EMDATA.STRNWQMI(label="Scored Train:"); code metabase=EMPROJ.T0R5N2UQ.SCRZNU0 group=RG residual; run; quit;
proc freq data=EMDATA.STRNWQMI; table F_RESPOND*I_RESPOND / out=EMPROJ.RGIOSUK3 outpct; run;
proc sql; reset noprint; create view EMPROJ.SMP_DMHY as select * from EMPROJ.DMRGZNU0; quit;
data EMPROJ._000tran(keep= _cost _aprofit _e_prob _e_count) EMPROJ._A00002X(keep= _nprofit _nobs _pmiss) EMPROJ._A00003A(keep= RESPOND P_RESPOND1 P_RESPOND0 EP_RESPOND_ BP_RESPOND_ CP_RESPOND_ _eprofit _cost _aprofit _warn_ _e_count _e_prob); set EMPROJ._A000039 end=_lastobn; length _aprofit 8 _Ftarget $%DMNORLEN; _cost = 0; _eprofit = EP_RESPOND_; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
if (_Ftarget = '' or _Ftarget = '.') and (NOT _lastobn) then delete; _e_prob = P_RESPOND1;
if _Ftarget = '1' then do; _e_count = 1; end;
else if _Ftarget = '0' then do; _e_count = 0; end;
_aprofit = CP_RESPOND_; _ncount + 1; output EMPROJ._000tran EMPROJ._A00003A; if _e_count > 0 then _nprofit + 1; if _eprofit = . then _pmiss + 1; if _lastobn then do; _nobs = _ncount; _pmiss = _pmiss/_n_; put _pmiss= _nobs= _nprofit=; output EMPROJ._A00002X; end; run;
data EMPROJ._A00003B; set EMPROJ._A00003A; drop _eprofit _cost _aprofit _freq_ _freqadj _e_: ic_: ep_: bp_: cp_: el_: bl_: cl_: ; drop _c000000; if _c000000 < 5000 then do; if ( (10000-_N_) * ranuni(12345) ) <= (5000-_c000000) then do; _c000000+1; output; end; end; run;
proc sort data=EMPROJ._A00003A ; by descending _e_prob; run;
data EMPROJ._A00002V(keep=_tool_ _decile _cutoff _eprofit _cap _lift _resp _capc _liftc _respc _gcount version); set EMPROJ._A00003A end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7; retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _resp9 _respc9 _cap9 _capc9 _lift9 _liftc9; rename _e_prob = _cutoff; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Regression"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _e_prob) < 1E-7 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0;
/*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_p = _e_prob; _tgcount = _tgcount + 1; if _e_count > 0 then do; _tcount = _tcount + 1; end; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; end; else do; _ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do; do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end;
_count = _gcount * _ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; end; else do; _tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; link do_out; end;
_ave = _tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0; _tcount = _tgcount * _tave; end; return;
do_out: _nobns = _nobns + _n_per_q; _q_out = _q_out + 1; _decile = 100 * _q_out / nquants; _cap = _n_per_q * _ave * 100 / n_y_1; _lift = _ave / ( n_y_1 / sumfreq); _resp = _ave * 100;
_countc = _countc + _n_per_q * _ave; _capc = (_countc / n_y_1) * 100; _liftc = _capc / _decile; _respc = (_countc / _nobns) * 100; if ^_lastobs then _eprofit = _prev_ep; if _q_out > 1 then do; if abs(_resp - _resp9 ) < 1E-7 then _resp = _resp9 ; if abs(_respc - _respc9 ) < 1E-7 then _respc = _respc9 ; if abs(_cap - _cap9 ) < 1E-7 then _cap = _cap9 ; if abs(_capc - _capc9 ) < 1E-7 then _capc = _capc9 ; if abs(_lift - _lift9 ) < 1E-7 then _lift = _lift9 ; if abs(_liftc - _liftc9 ) < 1E-7 then _liftc = _liftc9 ; end; if _q_out = 1 then do; _respc = _resp; _capc = _cap; _liftc = _lift; end; if ^_lastobs then _e_prob = _prev_ep; output;
if _q_out = 1 then do; _resp9 = _resp; _respc9 = _respc; _cap9 = _cap; _capc9 = _capc; _lift9 = _lift; _liftc9 = _liftc; end; else do; if abs(_resp - _resp9 ) > 1E-7 then _resp9 = _resp ; if abs(_respc - _respc9 ) > 1E-7 then _respc9 = _respc ; if abs(_cap - _cap9 ) > 1E-7 then _cap9 = _cap ; if abs(_capc - _capc9 ) > 1E-7 then _capc9 = _capc ; if abs(_lift - _lift9 ) > 1E-7 then _lift9 = _lift ; if abs(_liftc - _liftc9 ) > 1E-7 then _liftc9 = _liftc ; end; return; run;
proc sort data=EMPROJ._A00003A ; by descending _eprofit; run;
data EMPROJ._000LFT2(keep=_profit _roi _profitc _roic Tprofit Tprofitc proftype _iscost0); set EMPROJ._A00003A end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7;
retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _prev_ep 0; /* EP from previous observation. */ retain _prof2 0 _cost2 0 _tprof2 0 _tcost2 0; retain _profitc 0 _roic 0; retain _profit9 _proftc9 _roi9 _roic9; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Regression"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _eprofit) < 0.00001 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; _prof2 + _tprof2; _tprof2 = 0; _cost2 + _tcost2; _tcost2 = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_ep = _cur_ep; _eprofit = _cur_ep; _prev_p = _eprofit; _tgcount = _tgcount + 1; if _aprofit > 0.5 then do; _tcount = _tcount + 1; end; _tprof2 + _aprofit; _tcost2 + _cost; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; _p_ave = _prof2/_gcount; _c_ave = _cost2/_gcount; end; else do; _ave = 0; _p_ave = 0; _c_ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do; do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end; _count = _gcount * _ave; _prof2 = _gcount * _p_ave; _cost2 = _gcount * _c_ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; _p_tave = _tprof2/_tgcount; _c_tave = _tcost2/_tgcount; end; else do; _tave = 0; _p_tave = 0; _c_tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _p_ave = (_gcount * _p_ave + (_n_per_q - _gcount) * _p_tave) / _n_per_q; _c_ave = (_gcount * _c_ave + (_n_per_q - _gcount) * _c_tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; _prof2 = 0; _cost2 = 0; link do_out; end;
_ave = _tave; _p_ave = _p_tave; _c_ave = _c_tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0; _tcount = _tgcount * _tave; _tprof2 = _tgcount * _p_tave; _tcost2 = _tgcount * _c_tave; end; return;
do_out: _nobns = _nobns + _n_per_q; _q_out = _q_out + 1; _decile = 100 * _q_out / nquants; if ^_lastobs then _eprofit = _prev_ep; /* non-cummulative average profit, total profit, and average roi */ _eprofit = _prev_ep; _profit = _p_ave; Tprofit = _p_ave * _n_per_q; if _c_ave ^= 0 and _c_ave ^= . then do; _roi = _p_ave/_c_ave; _iscost0 = 'N'; end; else do; _roi = .; _iscost0 = 'Y'; end; /* cummulative average profit, total profit, and average roi */ if _roic ^= . and _roic ^= 0 then _costc = _profitc/_roic; else _costc = 0; _profitc = ((_profitc * (_nobns - _n_per_q)) + (_p_ave * _n_per_q)) /_nobns; Tprofitc = _profitc * _nobns; if (_costc + _c_ave * _n_per_q) ^= 0 then _roic = Tprofitc / (_costc * (_nobns - _n_per_q) + _c_ave * _n_per_q); else _roic = .; if _q_out > 1 then do; if abs(_profit - _profit9) < 0.00001 then _profit = _profit9 ; if abs(_profitc- _proftc9) < 0.00001 then _profitc = _proftc9 ; if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) < 1E-7 then _roi = _roi9 ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) < 1E-7 then _roic = _roic9 ; end; end; if _q_out = 1 then do; _profitc = _profit; _roic = _roi; end; output;
if _q_out = 1 then do; _profit9 = _profit; _proftc9 = _profitc; _roi9 = _roi; _roic9 = _roic; end; else do; if abs(_profit - _profit9) > 0.00001 then _profit9 = _profit ; if abs(_profitc- _proftc9) > 0.00001 then _proftc9 = _profitc; if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) > 1E-7 then _roi9 = _roi ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) > 1E-7 then _roic9 = _roic ; end; end; return; run;
data EMPROJ._A00002V; merge EMPROJ._A00002V EMPROJ._000LFT2; run;
proc sort data=EMPROJ._000tran ; by descending _e_count; run;
data EMPROJ._A00002Z(keep=_tool_ _decile _cutoff _eprofit _cap _lift _resp _capc _liftc _respc _gcount version); set EMPROJ._000tran end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7; retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/ retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */ retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */ retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _resp9 _respc9 _cap9 _capc9 _lift9 _liftc9; rename _e_prob = _cutoff; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Exact"; proftype = "PROFIT"; version = 3; link do_accum; /* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _e_count) < 1E-7 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_p = _e_count; _tgcount = _tgcount + 1; if _e_count > 0 then do; _tcount = _tcount + 1; end; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; end; else do; _ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do; do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end; _count = _gcount * _ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; end; else do; _tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; link do_out; end;
_ave = _tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0;
_tcount = _tgcount * _tave; end; return;
do_out: _nobns = _nobns + _n_per_q; _q_out = _q_out + 1; _decile = 100 * _q_out / nquants; _cap = _n_per_q * _ave * 100 / n_y_1; _lift = _ave / ( n_y_1 / sumfreq); _resp = _ave * 100;
_countc = _countc + _n_per_q * _ave; _capc = (_countc / n_y_1) * 100; _liftc = _capc / _decile; _respc = (_countc / _nobns) * 100; if ^_lastobs then _eprofit = _prev_ep; if _q_out > 1 then do; if abs(_resp - _resp9 ) < 1E-7 then _resp = _resp9 ; if abs(_respc - _respc9 ) < 1E-7 then _respc = _respc9 ; if abs(_cap - _cap9 ) < 1E-7 then _cap = _cap9 ; if abs(_capc - _capc9 ) < 1E-7 then _capc = _capc9 ; if abs(_lift - _lift9 ) < 1E-7 then _lift = _lift9 ; if abs(_liftc - _liftc9 ) < 1E-7 then _liftc = _liftc9 ; end; if _q_out = 1 then do; _respc = _resp; _capc = _cap; _liftc = _lift; end; _e_prob = .; if ^_lastobs then _e_prob = _prev_ep; output;
if _q_out = 1 then do; _resp9 = _resp; _respc9 = _respc; _cap9 = _cap; _capc9 = _capc; _lift9 = _lift; _liftc9 = _liftc; end; else do; if abs(_resp - _resp9 ) > 1E-7 then _resp9 = _resp ; if abs(_respc - _respc9 ) > 1E-7 then _respc9 = _respc ; if abs(_cap - _cap9 ) > 1E-7 then _cap9 = _cap ; if abs(_capc - _capc9 ) > 1E-7 then _capc9 = _capc ; if abs(_lift - _lift9 ) > 1E-7 then _lift9 = _lift ; if abs(_liftc - _liftc9 ) > 1E-7 then _liftc9 = _liftc ; end; return; run;
proc sort data=EMPROJ._000tran ; by descending _aprofit; run;
data EMPROJ._000LFT2(keep= _profit _roi _profitc _roic Tprofit Tprofitc proftype _iscost0); set EMPROJ._000tran end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7; retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */ retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _prev_ep 0; /* EP from previous observation. */ retain _prof2 0 _cost2 0 _tprof2 0 _tcost2 0; retain _profitc 0 _roic 0; retain _profit9 _proftc9 _roi9 _roic9; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Exact"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _aprofit) < 0.00001 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; _prof2 + _tprof2; _tprof2 = 0; _cost2 + _tcost2; _tcost2 = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_ep = _cur_ep; _prev_p = _aprofit; _tgcount = _tgcount + 1; if _aprofit > 0.5 then do; _tcount = _tcount + 1; end; _tprof2 + _aprofit; _tcost2 + _cost; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; _p_ave = _prof2/_gcount; _c_ave = _cost2/_gcount; end; else do; _ave = 0; _p_ave = 0; _c_ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do;
do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end;
_count = _gcount * _ave; _prof2 = _gcount * _p_ave; _cost2 = _gcount * _c_ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; _p_tave = _tprof2/_tgcount; _c_tave = _tcost2/_tgcount; end; else do; _tave = 0; _p_tave = 0; _c_tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _p_ave = (_gcount * _p_ave + (_n_per_q - _gcount) * _p_tave) / _n_per_q;
_c_ave = (_gcount * _c_ave + (_n_per_q - _gcount) * _c_tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; _prof2 = 0; _cost2 = 0; link do_out; end;
_ave = _tave; _p_ave = _p_tave; _c_ave = _c_tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0;
_tcount = _tgcount * _tave; _tprof2 = _tgcount * _p_tave; _tcost2 = _tgcount * _c_tave; end; return;
do_out: _nobns = _nobns + _n_per_q; _q_out = _q_out + 1; _decile = 100 * _q_out / nquants; if ^_lastobs then _eprofit = _prev_ep; /* non-cummulative average profit, total profit, and average roi */ _eprofit = _prev_ep; _profit = _p_ave; Tprofit = _p_ave * _n_per_q; if _c_ave ^= 0 and _c_ave ^= . then do; _roi = _p_ave/_c_ave; _iscost0 = 'N'; end; else do; _roi = .; _iscost0 = 'Y'; end; /* cummulative average profit, total profit, and average roi */ if _roic ^= . and _roic ^= 0 then _costc = _profitc/_roic; else _costc = 0; _profitc = ((_profitc * (_nobns - _n_per_q)) + (_p_ave * _n_per_q)) /_nobns; Tprofitc = _profitc * _nobns; if (_costc + _c_ave * _n_per_q) ^= 0 then _roic = Tprofitc / (_costc * (_nobns - _n_per_q) + _c_ave * _n_per_q); else _roic = .; if _q_out > 1 then do; if abs(_profit - _profit9) < 0.00001 then _profit = _profit9 ; if abs(_profitc- _proftc9) < 0.00001 then _profitc = _proftc9 ; if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) < 1E-7 then _roi = _roi9 ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) < 1E-7 then _roic = _roic9 ; end; end; if _q_out = 1 then do; _profitc = _profit; _roic = _roi; end; _e_prob = .; output;
if _q_out = 1 then do; _profit9 = _profit; _proftc9 = _profitc; _roi9 = _roi; _roic9 = _roic; end; else do; if abs(_profit - _profit9) > 0.00001 then _profit9 = _profit ; if abs(_profitc- _proftc9) > 0.00001 then _proftc9 = _profitc;
if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) > 1E-7 then _roi9 = _roi ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) > 1E-7 then _roic9 = _roic ; end; end; return; run;
data EMPROJ._A00002Z; merge EMPROJ._A00002Z EMPROJ._000LFT2; run;
data EMPROJ._A00002Y; set EMPROJ._A00002V end=_lastobs; length modelid $8; drop _resp _respc _profit _profitc _roi _roic x _decile; drop _lift _liftc cont_cap big_diff tprofit tprofitc; rename _resp2 = _resp; rename _respc2 = _respc; rename _profit2 = _profit; rename _proftc2 = _profitc; rename _roi2 = _roi; rename _roic2 = _roic; rename _lift2 = _lift; rename _liftc2 = _liftc; rename tprofit2 = tprofit; rename tproftc2 = tprofitc;
retain cont_cap; retain big_diff 0; modelid = 'Baseline'; _tool_ = 'Baseline'; modelnam = 'Baseline'; if _n_ = 1 then cont_cap = _cap; if abs(cont_cap - _cap) > 0.00001 then big_diff = 1; if _lastobs then do x = 1 to 10; _eprofit = .; _cutoff = .; _resp2 = _respc; _respc2 = _respc;
if big_diff then _cap = 100 / 10; else _cap = cont_cap;
_capc = (100 / 10) * x; _lift2 = _liftc; _liftc2 = _liftc; _profit2 = _profitc; _proftc2 = _profitc; tprofit2 = _profitc * _gcount; tproftc2 = (_profitc * _gcount) * x; _roi2 = _roic; _roic2 = _roic; output; end; run;
data EMPROJ._A00002Y; merge EMPROJ._A00002V EMPROJ._A00002Y; run;
data EMPROJ._000tmp1(keep= _TARGET _OUTPUT); set EMPROJ._A00003A; length _aTarget _pTarget $16; rename _pTarget=_OUTPUT _aTarget=_TARGET; _aTarget = left(trim(put(RESPOND,BEST12.))); if P_RESPOND1 >= P_RESPOND0 then _pTarget = '1'; else _pTarget = '0'; run;
proc freq data=EMPROJ._000tmp1(rename=(_target=target _output=output)) noprint; table target * output / out=EMPROJ._A000032; table target /out=EMPROJ._000tmp3(keep=target count rename=(count=total)); quit;
data EMPROJ._A000032(drop =total); merge EMPROJ._A000032 EMPROJ._000tmp3; by target; label lvl_per = 'Percent'; lvl_per = (count/total) * 100; run;
data EMPROJ._A000032; set EMPROJ._A000032; target = upcase(target); run;
proc sort data=EMPROJ._A000032; by target output; run;
data EMPROJ._000tmp5(keep=target); set EMPROJ._A000032; run;
proc sort data=EMPROJ._000tmp5 NODUP; by target; run;
data EMPROJ._000tmp6; length target $%DMNORLEN output $%DMNORLEN count 8 percent 8 lvl_per 8; target = 'X'; output='X'; count=0;percent=0; lvl_per=0; stop; run;
proc sort data=EMPROJ._000tmp6; by target output; run;
proc sort data=EMPROJ._A000032; by target output; run;
data EMPROJ._A000032; update EMPROJ._000tmp6 EMPROJ._A000032; by target output; run;
data EMPROJ._A000036(keep=_tool _cutoff _avg _freq _lvlord rename=(_cutoff=cutoff _avg=avg _freq=freq _tool=tool _lvlord=lvlord)); set EMPROJ._A00003A end=last_obn; length _tool $15 _cutoff $2 _avg 8 _freq 8 _lvlord $1 _Ftarget $%DMNORLEN; drop _Ftarget; retain _afrq95 0 _afrq90 0 _afrq85 0 _afrq80 0 _afrq75 0 _afrq70 0 _afrq65 0 _afrq60 0 _afrq55 0 _afrq50 0 _afrq45 0 _afrq40 0 _afrq35 0 _afrq30 0 _afrq25 0 _afrq20 0 _afrq15 0 _afrq10 0 _afrq05 0 _acrt95 0 _acrt90 0 _acrt85 0 _acrt80 0 _acrt75 0 _acrt70 0 _acrt65 0 _acrt60 0 _acrt55 0 _acrt50 0 _acrt45 0 _acrt40 0 _acrt35 0 _acrt30 0 _acrt25 0 _acrt20 0 _acrt15 0 _acrt10 0 _acrt05 0 _bfrq95 0 _bfrq90 0 _bfrq85 0 _bfrq80 0 _bfrq75 0 _bfrq70 0 _bfrq65 0 _bfrq60 0 _bfrq55 0 _bfrq50 0 _bfrq45 0 _bfrq40 0 _bfrq35 0 _bfrq30 0 _bfrq25 0 _bfrq20 0 _bfrq15 0 _bfrq10 0 _bfrq05 0 _bcrt95 0 _bcrt90 0 _bcrt85 0 _bcrt80 0 _bcrt75 0 _bcrt70 0 _bcrt65 0 _bcrt60 0 _bcrt55 0 _bcrt50 0 _bcrt45 0 _bcrt40 0 _bcrt35 0 _bcrt30 0 _bcrt25 0 _bcrt20 0 _bcrt15 0 _bcrt10 0 _bcrt05 0;
_tool = "Regression"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if _Ftarget = '1' then _acrt = 1; else _acrt = 0;
if P_RESPOND1 >= .95 then link A95; if P_RESPOND1 >= .90 then link A90; if P_RESPOND1 >= .85 then link A85; if P_RESPOND1 >= .80 then link A80; if P_RESPOND1 >= .75 then link A75; if P_RESPOND1 >= .70 then link A70; if P_RESPOND1 >= .65 then link A65; if P_RESPOND1 >= .60 then link A60; if P_RESPOND1 >= .55 then link A55; if P_RESPOND1 >= .50 then link A50; if P_RESPOND1 >= .45 then link A45; if P_RESPOND1 >= .40 then link A40; if P_RESPOND1 >= .35 then link A35; if P_RESPOND1 >= .30 then link A30; if P_RESPOND1 >= .25 then link A25; if P_RESPOND1 >= .20 then link A20; if P_RESPOND1 >= .15 then link A15; if P_RESPOND1 >= .10 then link A10; if P_RESPOND1 >= .05 then link A05; /* process target level 2 */ if _Ftarget = '0' then _bcrt = 1; else _bcrt = 0;
if P_RESPOND0 >= .95 then link B95; if P_RESPOND0 >= .90 then link B90; if P_RESPOND0 >= .85 then link B85; if P_RESPOND0 >= .80 then link B80; if P_RESPOND0 >= .75 then link B75; if P_RESPOND0 >= .70 then link B70; if P_RESPOND0 >= .65 then link B65; if P_RESPOND0 >= .60 then link B60; if P_RESPOND0 >= .55 then link B55; if P_RESPOND0 >= .50 then link B50; if P_RESPOND0 >= .45 then link B45; if P_RESPOND0 >= .40 then link B40; if P_RESPOND0 >= .35 then link B35; if P_RESPOND0 >= .30 then link B30; if P_RESPOND0 >= .25 then link B25; if P_RESPOND0 >= .20 then link B20; if P_RESPOND0 >= .15 then link B15; if P_RESPOND0 >= .10 then link B10; if P_RESPOND0 >= .05 then link B05;
if last_obn then do; if _afrq95 > 0 then _aavg95 = _acrt95 / _afrq95; if _afrq90 > 0 then _aavg90 = _acrt90 / _afrq90; if _afrq85 > 0 then _aavg85 = _acrt85 / _afrq85; if _afrq80 > 0 then _aavg80 = _acrt80 / _afrq80; if _afrq75 > 0 then _aavg75 = _acrt75 / _afrq75; if _afrq70 > 0 then _aavg70 = _acrt70 / _afrq70; if _afrq65 > 0 then _aavg65 = _acrt65 / _afrq65; if _afrq60 > 0 then _aavg60 = _acrt60 / _afrq60; if _afrq55 > 0 then _aavg55 = _acrt55 / _afrq55; if _afrq50 > 0 then _aavg50 = _acrt50 / _afrq50; if _afrq45 > 0 then _aavg45 = _acrt45 / _afrq45; if _afrq40 > 0 then _aavg40 = _acrt40 / _afrq40; if _afrq35 > 0 then _aavg35 = _acrt35 / _afrq35; if _afrq30 > 0 then _aavg30 = _acrt30 / _afrq30; if _afrq25 > 0 then _aavg25 = _acrt25 / _afrq25; if _afrq20 > 0 then _aavg20 = _acrt20 / _afrq20; if _afrq15 > 0 then _aavg15 = _acrt15 / _afrq15; if _afrq10 > 0 then _aavg10 = _acrt10 / _afrq10; if _afrq05 > 0 then _aavg05 = _acrt05 / _afrq05; if _bfrq95 > 0 then _bavg95 = _bcrt95 / _bfrq95; if _bfrq90 > 0 then _bavg90 = _bcrt90 / _bfrq90; if _bfrq85 > 0 then _bavg85 = _bcrt85 / _bfrq85; if _bfrq80 > 0 then _bavg80 = _bcrt80 / _bfrq80; if _bfrq75 > 0 then _bavg75 = _bcrt75 / _bfrq75; if _bfrq70 > 0 then _bavg70 = _bcrt70 / _bfrq70; if _bfrq65 > 0 then _bavg65 = _bcrt65 / _bfrq65; if _bfrq60 > 0 then _bavg60 = _bcrt60 / _bfrq60; if _bfrq55 > 0 then _bavg55 = _bcrt55 / _bfrq55; if _bfrq50 > 0 then _bavg50 = _bcrt50 / _bfrq50; if _bfrq45 > 0 then _bavg45 = _bcrt45 / _bfrq45; if _bfrq40 > 0 then _bavg40 = _bcrt40 / _bfrq40; if _bfrq35 > 0 then _bavg35 = _bcrt35 / _bfrq35; if _bfrq30 > 0 then _bavg30 = _bcrt30 / _bfrq30; if _bfrq25 > 0 then _bavg25 = _bcrt25 / _bfrq25; if _bfrq20 > 0 then _bavg20 = _bcrt20 / _bfrq20; if _bfrq15 > 0 then _bavg15 = _bcrt15 / _bfrq15; if _bfrq10 > 0 then _bavg10 = _bcrt10 / _bfrq10; if _bfrq05 > 0 then _bavg05 = _bcrt05 / _bfrq05; _cutoff='95';_avg=_aavg95;_freq=_afrq95;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='90';_avg=_aavg90;_freq=_afrq90;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='85';_avg=_aavg85;_freq=_afrq85;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='80';_avg=_aavg80;_freq=_afrq80;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='75';_avg=_aavg75;_freq=_afrq75;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='70';_avg=_aavg70;_freq=_afrq70;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='65';_avg=_aavg65;_freq=_afrq65;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='60';_avg=_aavg60;_freq=_afrq60;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='55';_avg=_aavg55;_freq=_afrq55;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='50';_avg=_aavg50;_freq=_afrq50;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='45';_avg=_aavg45;_freq=_afrq45;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='40';_avg=_aavg40;_freq=_afrq40;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='35';_avg=_aavg35;_freq=_afrq35;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='30';_avg=_aavg30;_freq=_afrq30;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='25';_avg=_aavg25;_freq=_afrq25;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='20';_avg=_aavg20;_freq=_afrq20;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='15';_avg=_aavg15;_freq=_afrq15;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='10';_avg=_aavg10;_freq=_afrq10;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='05';_avg=_aavg05;_freq=_afrq05;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='95';_avg=_bavg95;_freq=_bfrq95;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='90';_avg=_bavg90;_freq=_bfrq90;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='85';_avg=_bavg85;_freq=_bfrq85;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='80';_avg=_bavg80;_freq=_bfrq80;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='75';_avg=_bavg75;_freq=_bfrq75;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='70';_avg=_bavg70;_freq=_bfrq70;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='65';_avg=_bavg65;_freq=_bfrq65;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='60';_avg=_bavg60;_freq=_bfrq60;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='55';_avg=_bavg55;_freq=_bfrq55;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='50';_avg=_bavg50;_freq=_bfrq50;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='45';_avg=_bavg45;_freq=_bfrq45;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='40';_avg=_bavg40;_freq=_bfrq40;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='35';_avg=_bavg35;_freq=_bfrq35;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='30';_avg=_bavg30;_freq=_bfrq30;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='25';_avg=_bavg25;_freq=_bfrq25;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='20';_avg=_bavg20;_freq=_bfrq20;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='15';_avg=_bavg15;_freq=_bfrq15;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='10';_avg=_bavg10;_freq=_bfrq10;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='05';_avg=_bavg05;_freq=_bfrq05;_lvlord='B'; if _avg=. then _avg=0;output; end; return; A95: _afrq95 = _afrq95 + 1; if _acrt = 1 then _acrt95 = _acrt95 + 1; return; A90: _afrq90 = _afrq90 + 1; if _acrt = 1 then _acrt90 = _acrt90 + 1; return; A85: _afrq85 = _afrq85 + 1; if _acrt = 1 then _acrt85 = _acrt85 + 1; return; A80: _afrq80 = _afrq80 + 1; if _acrt = 1 then _acrt80 = _acrt80 + 1; return; A75: _afrq75 = _afrq75 + 1; if _acrt = 1 then _acrt75 = _acrt75 + 1; return; A70: _afrq70 = _afrq70 + 1; if _acrt = 1 then _acrt70 = _acrt70 + 1; return; A65: _afrq65 = _afrq65 + 1; if _acrt = 1 then _acrt65 = _acrt65 + 1; return; A60: _afrq60 = _afrq60 + 1; if _acrt = 1 then _acrt60 = _acrt60 + 1; return; A55: _afrq55 = _afrq55 + 1; if _acrt = 1 then _acrt55 = _acrt55 + 1; return; A50: _afrq50 = _afrq50 + 1; if _acrt = 1 then _acrt50 = _acrt50 + 1; return; A45: _afrq45 = _afrq45 + 1; if _acrt = 1 then _acrt45 = _acrt45 + 1; return; A40: _afrq40 = _afrq40 + 1; if _acrt = 1 then _acrt40 = _acrt40 + 1; return; A35: _afrq35 = _afrq35 + 1; if _acrt = 1 then _acrt35 = _acrt35 + 1; return; A30: _afrq30 = _afrq30 + 1; if _acrt = 1 then _acrt30 = _acrt30 + 1; return; A25: _afrq25 = _afrq25 + 1; if _acrt = 1 then _acrt25 = _acrt25 + 1; return; A20: _afrq20 = _afrq20 + 1; if _acrt = 1 then _acrt20 = _acrt20 + 1; return; A15: _afrq15 = _afrq15 + 1; if _acrt = 1 then _acrt15 = _acrt15 + 1; return; A10: _afrq10 = _afrq10 + 1; if _acrt = 1 then _acrt10 = _acrt10 + 1; return; A05: _afrq05 = _afrq05 + 1; if _acrt = 1 then _acrt05 = _acrt05 + 1; return; B95: _bfrq95 = _bfrq95 + 1; if _bcrt = 1 then _bcrt95 = _bcrt95 + 1; return; B90: _bfrq90 = _bfrq90 + 1; if _bcrt = 1 then _bcrt90 = _bcrt90 + 1; return; B85: _bfrq85 = _bfrq85 + 1; if _bcrt = 1 then _bcrt85 = _bcrt85 + 1; return; B80: _bfrq80 = _bfrq80 + 1; if _bcrt = 1 then _bcrt80 = _bcrt80 + 1; return; B75: _bfrq75 = _bfrq75 + 1; if _bcrt = 1 then _bcrt75 = _bcrt75 + 1; return; B70: _bfrq70 = _bfrq70 + 1; if _bcrt = 1 then _bcrt70 = _bcrt70 + 1; return; B65: _bfrq65 = _bfrq65 + 1; if _bcrt = 1 then _bcrt65 = _bcrt65 + 1; return; B60: _bfrq60 = _bfrq60 + 1; if _bcrt = 1 then _bcrt60 = _bcrt60 + 1; return; B55: _bfrq55 = _bfrq55 + 1; if _bcrt = 1 then _bcrt55 = _bcrt55 + 1; return; B50: _bfrq50 = _bfrq50 + 1; if _bcrt = 1 then _bcrt50 = _bcrt50 + 1; return; B45: _bfrq45 = _bfrq45 + 1; if _bcrt = 1 then _bcrt45 = _bcrt45 + 1; return; B40: _bfrq40 = _bfrq40 + 1; if _bcrt = 1 then _bcrt40 = _bcrt40 + 1; return; B35: _bfrq35 = _bfrq35 + 1; if _bcrt = 1 then _bcrt35 = _bcrt35 + 1; return; B30: _bfrq30 = _bfrq30 + 1; if _bcrt = 1 then _bcrt30 = _bcrt30 + 1; return; B25: _bfrq25 = _bfrq25 + 1; if _bcrt = 1 then _bcrt25 = _bcrt25 + 1; return; B20: _bfrq20 = _bfrq20 + 1; if _bcrt = 1 then _bcrt20 = _bcrt20 + 1; return; B15: _bfrq15 = _bfrq15 + 1; if _bcrt = 1 then _bcrt15 = _bcrt15 + 1; return; B10: _bfrq10 = _bfrq10 + 1; if _bcrt = 1 then _bcrt10 = _bcrt10 + 1; return; B05: _bfrq05 = _bfrq05 + 1; if _bcrt = 1 then _bcrt05 = _bcrt05 + 1; return; run;
data EMPROJ._000sroc(keep=_tool _se _sp _lvlord rename=(_se=se _sp=sp _tool=tool _lvlord=lvlord)); set EMPROJ._A00003A end=last_obn; length _tool $15 _lvlord $1 _Ftarget $%DMNORLEN; drop _Ftarget; retain _aa99 _ab99 _ac99 _ad99 _aa95 _ab95 _ac95 _ad95 _aa90 _ab90 _ac90 _ad90 _aa85 _ab85 _ac85 _ad85 _aa80 _ab80 _ac80 _ad80 _aa75 _ab75 _ac75 _ad75 _aa70 _ab70 _ac70 _ad70 _aa65 _ab65 _ac65 _ad65 _aa60 _ab60 _ac60 _ad60 _aa55 _ab55 _ac55 _ad55 _aa50 _ab50 _ac50 _ad50 _aa45 _ab45 _ac45 _ad45 _aa40 _ab40 _ac40 _ad40 _aa35 _ab35 _ac35 _ad35 _aa30 _ab30 _ac30 _ad30 _aa25 _ab25 _ac25 _ad25 _aa20 _ab20 _ac20 _ad20 _aa15 _ab15 _ac15 _ad15 _aa10 _ab10 _ac10 _ad10 _aa05 _ab05 _ac05 _ad05 _aa00 _ab00 _ac00 _ad00 _ba99 _bb99 _bc99 _bd99 _ba95 _bb95 _bc95 _bd95 _ba90 _bb90 _bc90 _bd90 _ba85 _bb85 _bc85 _bd85 _ba80 _bb80 _bc80 _bd80 _ba75 _bb75 _bc75 _bd75 _ba70 _bb70 _bc70 _bd70 _ba65 _bb65 _bc65 _bd65 _ba60 _bb60 _bc60 _bd60 _ba55 _bb55 _bc55 _bd55 _ba50 _bb50 _bc50 _bd50 _ba45 _bb45 _bc45 _bd45 _ba40 _bb40 _bc40 _bd40 _ba35 _bb35 _bc35 _bd35 _ba30 _bb30 _bc30 _bd30 _ba25 _bb25 _bc25 _bd25 _ba20 _bb20 _bc20 _bd20 _ba15 _bb15 _bc15 _bd15 _ba10 _bb10 _bc10 _bd10 _ba05 _bb05 _bc05 _bd05 _ba00 _bb00 _bc00 _bd00 0;
_tool = "Regression"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if P_RESPOND1 = 1 then do; if _Ftarget = '1' then _aa99 = _aa99 + 1; else _ab99 = _ab99 + 1; end; else do; if _Ftarget = '1' then _ac99 = _ac99 + 1; else _ad99 = _ad99 + 1; end;
if P_RESPOND1 >= .95 then do; if _Ftarget = '1' then _aa95 = _aa95 + 1; else _ab95 = _ab95 + 1; end; else do; if _Ftarget = '1' then _ac95 = _ac95 + 1; else _ad95 = _ad95 + 1; end;
if P_RESPOND1 >= .90 then do; if _Ftarget = '1' then _aa90 = _aa90 + 1; else _ab90 = _ab90 + 1; end; else do; if _Ftarget = '1' then _ac90 = _ac90 + 1; else _ad90 = _ad90 + 1; end;
if P_RESPOND1 >= .85 then do; if _Ftarget = '1' then _aa85 = _aa85 + 1; else _ab85 = _ab85 + 1; end; else do; if _Ftarget = '1' then _ac85 = _ac85 + 1; else _ad85 = _ad85 + 1; end;
if P_RESPOND1 >= .80 then do; if _Ftarget = '1' then _aa80 = _aa80 + 1; else _ab80 = _ab80 + 1; end; else do; if _Ftarget = '1' then _ac80 = _ac80 + 1; else _ad80 = _ad80 + 1; end;
if P_RESPOND1 >= .75 then do; if _Ftarget = '1' then _aa75 = _aa75 + 1; else _ab75 = _ab75 + 1; end; else do; if _Ftarget = '1' then _ac75 = _ac75 + 1; else _ad75 = _ad75 + 1; end;
if P_RESPOND1 >= .70 then do; if _Ftarget = '1' then _aa70 = _aa70 + 1; else _ab70 = _ab70 + 1; end; else do; if _Ftarget = '1' then _ac70 = _ac70 + 1; else _ad70 = _ad70 + 1; end;
if P_RESPOND1 >= .65 then do; if _Ftarget = '1' then _aa65 = _aa65 + 1; else _ab65 = _ab65 + 1; end; else do; if _Ftarget = '1' then _ac65 = _ac65 + 1; else _ad65 = _ad65 + 1; end;
if P_RESPOND1 >= .60 then do; if _Ftarget = '1' then _aa60 = _aa60 + 1; else _ab60 = _ab60 + 1; end; else do; if _Ftarget = '1' then _ac60 = _ac60 + 1; else _ad60 = _ad60 + 1; end;
if P_RESPOND1 >= .55 then do; if _Ftarget = '1' then _aa55 = _aa55 + 1; else _ab55 = _ab55 + 1; end; else do; if _Ftarget = '1' then _ac55 = _ac55 + 1; else _ad55 = _ad55 + 1; end;
if P_RESPOND1 >= .50 then do; if _Ftarget = '1' then _aa50 = _aa50 + 1; else _ab50 = _ab50 + 1; end; else do; if _Ftarget = '1' then _ac50 = _ac50 + 1; else _ad50 = _ad50 + 1; end;
if P_RESPOND1 >= .45 then do; if _Ftarget = '1' then _aa45 = _aa45 + 1; else _ab45 = _ab45 + 1; end; else do; if _Ftarget = '1' then _ac45 = _ac45 + 1; else _ad45 = _ad45 + 1; end;
if P_RESPOND1 >= .40 then do; if _Ftarget = '1' then _aa40 = _aa40 + 1; else _ab40 = _ab40 + 1; end; else do; if _Ftarget = '1' then _ac40 = _ac40 + 1; else _ad40 = _ad40 + 1; end;
if P_RESPOND1 >= .35 then do; if _Ftarget = '1' then _aa35 = _aa35 + 1; else _ab35 = _ab35 + 1; end; else do; if _Ftarget = '1' then _ac35 = _ac35 + 1; else _ad35 = _ad35 + 1; end;
if P_RESPOND1 >= .30 then do; if _Ftarget = '1' then _aa30 = _aa30 + 1; else _ab30 = _ab30 + 1; end; else do; if _Ftarget = '1' then _ac30 = _ac30 + 1; else _ad30 = _ad30 + 1; end;
if P_RESPOND1 >= .25 then do; if _Ftarget = '1' then _aa25 = _aa25 + 1; else _ab25 = _ab25 + 1; end; else do; if _Ftarget = '1' then _ac25 = _ac25 + 1; else _ad25 = _ad25 + 1; end;
if P_RESPOND1 >= .20 then do; if _Ftarget = '1' then _aa20 = _aa20 + 1; else _ab20 = _ab20 + 1; end; else do; if _Ftarget = '1' then _ac20 = _ac20 + 1; else _ad20 = _ad20 + 1; end;
if P_RESPOND1 >= .15 then do; if _Ftarget = '1' then _aa15 = _aa15 + 1; else _ab15 = _ab15 + 1; end; else do; if _Ftarget = '1' then _ac15 = _ac15 + 1; else _ad15 = _ad15 + 1; end;
if P_RESPOND1 >= .10 then do; if _Ftarget = '1' then _aa10 = _aa10 + 1; else _ab10 = _ab10 + 1; end; else do; if _Ftarget = '1' then _ac10 = _ac10 + 1; else _ad10 = _ad10 + 1; end;
if P_RESPOND1 >= .05 then do; if _Ftarget = '1' then _aa05 = _aa05 + 1; else _ab05 = _ab05 + 1; end; else do; if _Ftarget = '1' then _ac05 = _ac05 + 1; else _ad05 = _ad05 + 1; end;
if P_RESPOND1 >= 0 then do; if _Ftarget = '1' then _aa00 = _aa00 + 1; else _ab00 = _ab00 + 1; end; /* process target level 2 */ if P_RESPOND0 = 1 then do; if _Ftarget = '0' then _ba99 = _ba99 + 1; else _bb99 = _bb99 + 1; end; else do; if _Ftarget = '0' then _bc99 = _bc99 + 1; else _bd99 = _bd99 + 1; end;
if P_RESPOND0 >= .95 then do; if _Ftarget = '0' then _ba95 = _ba95 + 1; else _bb95 = _bb95 + 1; end; else do; if _Ftarget = '0' then _bc95 = _bc95 + 1; else _bd95 = _bd95 + 1; end;
if P_RESPOND0 >= .90 then do; if _Ftarget = '0' then _ba90 = _ba90 + 1; else _bb90 = _bb90 + 1; end; else do; if _Ftarget = '0' then _bc90 = _bc90 + 1; else _bd90 = _bd90 + 1; end;
if P_RESPOND0 >= .85 then do; if _Ftarget = '0' then _ba85 = _ba85 + 1; else _bb85 = _bb85 + 1; end; else do; if _Ftarget = '0' then _bc85 = _bc85 + 1; else _bd85 = _bd85 + 1; end;
if P_RESPOND0 >= .80 then do; if _Ftarget = '0' then _ba80 = _ba80 + 1; else _bb80 = _bb80 + 1; end; else do; if _Ftarget = '0' then _bc80 = _bc80 + 1; else _bd80 = _bd80 + 1; end;
if P_RESPOND0 >= .75 then do; if _Ftarget = '0' then _ba75 = _ba75 + 1; else _bb75 = _bb75 + 1; end; else do; if _Ftarget = '0' then _bc75 = _bc75 + 1; else _bd75 = _bd75 + 1; end;
if P_RESPOND0 >= .70 then do; if _Ftarget = '0' then _ba70 = _ba70 + 1; else _bb70 = _bb70 + 1; end; else do; if _Ftarget = '0' then _bc70 = _bc70 + 1; else _bd70 = _bd70 + 1; end;
if P_RESPOND0 >= .65 then do; if _Ftarget = '0' then _ba65 = _ba65 + 1; else _bb65 = _bb65 + 1; end; else do; if _Ftarget = '0' then _bc65 = _bc65 + 1; else _bd65 = _bd65 + 1; end;
if P_RESPOND0 >= .60 then do; if _Ftarget = '0' then _ba60 = _ba60 + 1; else _bb60 = _bb60 + 1; end; else do; if _Ftarget = '0' then _bc60 = _bc60 + 1; else _bd60 = _bd60 + 1; end;
if P_RESPOND0 >= .55 then do; if _Ftarget = '0' then _ba55 = _ba55 + 1; else _bb55 = _bb55 + 1; end; else do; if _Ftarget = '0' then _bc55 = _bc55 + 1; else _bd55 = _bd55 + 1; end;
if P_RESPOND0 >= .50 then do; if _Ftarget = '0' then _ba50 = _ba50 + 1; else _bb50 = _bb50 + 1; end; else do; if _Ftarget = '0' then _bc50 = _bc50 + 1; else _bd50 = _bd50 + 1; end;
if P_RESPOND0 >= .45 then do; if _Ftarget = '0' then _ba45 = _ba45 + 1; else _bb45 = _bb45 + 1; end; else do; if _Ftarget = '0' then _bc45 = _bc45 + 1; else _bd45 = _bd45 + 1; end;
if P_RESPOND0 >= .40 then do; if _Ftarget = '0' then _ba40 = _ba40 + 1; else _bb40 = _bb40 + 1; end; else do; if _Ftarget = '0' then _bc40 = _bc40 + 1; else _bd40 = _bd40 + 1; end;
if P_RESPOND0 >= .35 then do; if _Ftarget = '0' then _ba35 = _ba35 + 1; else _bb35 = _bb35 + 1; end; else do; if _Ftarget = '0' then _bc35 = _bc35 + 1; else _bd35 = _bd35 + 1; end;
if P_RESPOND0 >= .30 then do; if _Ftarget = '0' then _ba30 = _ba30 + 1; else _bb30 = _bb30 + 1; end; else do; if _Ftarget = '0' then _bc30 = _bc30 + 1; else _bd30 = _bd30 + 1; end;
if P_RESPOND0 >= .25 then do; if _Ftarget = '0' then _ba25 = _ba25 + 1; else _bb25 = _bb25 + 1; end; else do; if _Ftarget = '0' then _bc25 = _bc25 + 1; else _bd25 = _bd25 + 1; end;
if P_RESPOND0 >= .20 then do; if _Ftarget = '0' then _ba20 = _ba20 + 1; else _bb20 = _bb20 + 1; end; else do; if _Ftarget = '0' then _bc20 = _bc20 + 1; else _bd20 = _bd20 + 1; end;
if P_RESPOND0 >= .15 then do; if _Ftarget = '0' then _ba15 = _ba15 + 1; else _bb15 = _bb15 + 1; end; else do; if _Ftarget = '0' then _bc15 = _bc15 + 1; else _bd15 = _bd15 + 1; end;
if P_RESPOND0 >= .10 then do; if _Ftarget = '0' then _ba10 = _ba10 + 1; else _bb10 = _bb10 + 1; end; else do; if _Ftarget = '0' then _bc10 = _bc10 + 1; else _bd10 = _bd10 + 1; end;
if P_RESPOND0 >= .05 then do; if _Ftarget = '0' then _ba05 = _ba05 + 1; else _bb05 = _bb05 + 1; end; else do; if _Ftarget = '0' then _bc05 = _bc05 + 1; else _bd05 = _bd05 + 1; end;
if P_RESPOND0 >= 0 then do; if _Ftarget = '0' then _ba00 = _ba00 + 1; else _bb00 = _bb00 + 1; end; /* else do; * will never get hee * if _Ftarget = '0' then _bc00 = _bc00 + 1; else _bd00 = _bd00 + 1; end; */ if last_obn then do; if (_aa99+_ac99)> 0 then _se = _aa99/(_aa99+_ac99); else _se = 0; if (_ab99+_ad99)> 0 then _sp = 1-(_ad99/(_ab99+_ad99)); else _sp = 0; _lvlord = 'A'; output;
if (_aa95+_ac95)> 0 then _se = _aa95/(_aa95+_ac95); else _se = 0; if (_ab95+_ad95)> 0 then _sp = 1-(_ad95/(_ab95+_ad95)); else _sp = 0; _lvlord = 'A'; output;
if (_aa90+_ac90)> 0 then _se = _aa90/(_aa90+_ac90); else _se = 0; if (_ab90+_ad90)> 0 then _sp = 1-(_ad90/(_ab90+_ad90)); else _sp = 0; _lvlord = 'A'; output;
if (_aa85+_ac85)> 0 then _se = _aa85/(_aa85+_ac85); else _se = 0; if (_ab85+_ad85)> 0 then _sp = 1-(_ad85/(_ab85+_ad85)); else _sp = 0; _lvlord = 'A'; output;
if (_aa80+_ac80)> 0 then _se = _aa80/(_aa80+_ac80); else _se = 0; if (_ab80+_ad80)> 0 then _sp = 1-(_ad80/(_ab80+_ad80)); else _sp = 0; _lvlord = 'A'; output;
if (_aa75+_ac75)> 0 then _se = _aa75/(_aa75+_ac75); else _se = 0; if (_ab75+_ad75)> 0 then _sp = 1-(_ad75/(_ab75+_ad75)); else _sp = 0; _lvlord = 'A'; output;
if (_aa70+_ac70)> 0 then _se = _aa70/(_aa70+_ac70); else _se = 0; if (_ab70+_ad70)> 0 then _sp = 1-(_ad70/(_ab70+_ad70)); else _sp = 0; _lvlord = 'A'; output;
if (_aa65+_ac65)> 0 then _se = _aa65/(_aa65+_ac65); else _se = 0; if (_ab65+_ad65)> 0 then _sp = 1-(_ad65/(_ab65+_ad65)); else _sp = 0; _lvlord = 'A'; output;
if (_aa60+_ac60)> 0 then _se = _aa60/(_aa60+_ac60); else _se = 0; if (_ab60+_ad60)> 0 then _sp = 1-(_ad60/(_ab60+_ad60)); else _sp = 0; _lvlord = 'A'; output;
if (_aa55+_ac55)> 0 then _se = _aa55/(_aa55+_ac55); else _se = 0; if (_ab55+_ad55)> 0 then _sp = 1-(_ad55/(_ab55+_ad55)); else _sp = 0; _lvlord = 'A'; output;
if (_aa50+_ac50)> 0 then _se = _aa50/(_aa50+_ac50); else _se = 0; if (_ab50+_ad50)> 0 then _sp = 1-(_ad50/(_ab50+_ad50)); else _sp = 0; _lvlord = 'A'; output;
if (_aa45+_ac45)> 0 then _se = _aa45/(_aa45+_ac45); else _se = 0; if (_ab45+_ad45)> 0 then _sp = 1-(_ad45/(_ab45+_ad45)); else _sp = 0; _lvlord = 'A'; output;
if (_aa40+_ac40)> 0 then _se = _aa40/(_aa40+_ac40); else _se = 0; if (_ab40+_ad40)> 0 then _sp = 1-(_ad40/(_ab40+_ad40)); else _sp = 0; _lvlord = 'A'; output;
if (_aa35+_ac35)> 0 then _se = _aa35/(_aa35+_ac35); else _se = 0; if (_ab35+_ad35)> 0 then _sp = 1-(_ad35/(_ab35+_ad35)); else _sp = 0; _lvlord = 'A'; output;
if (_aa30+_ac30)> 0 then _se = _aa30/(_aa30+_ac30); else _se = 0; if (_ab30+_ad30)> 0 then _sp = 1-(_ad30/(_ab30+_ad30)); else _sp = 0; _lvlord = 'A'; output;
if (_aa25+_ac25)> 0 then _se = _aa25/(_aa25+_ac25); else _se = 0; if (_ab25+_ad25)> 0 then _sp = 1-(_ad25/(_ab25+_ad25)); else _sp = 0; _lvlord = 'A'; output;
if (_aa20+_ac20)> 0 then _se = _aa20/(_aa20+_ac20); else _se = 0; if (_ab20+_ad20)> 0 then _sp = 1-(_ad20/(_ab20+_ad20)); else _sp = 0; _lvlord = 'A'; output;
if (_aa15+_ac15)> 0 then _se = _aa15/(_aa15+_ac15); else _se = 0; if (_ab15+_ad15)> 0 then _sp = 1-(_ad15/(_ab15+_ad15)); else _sp = 0; _lvlord = 'A'; output;
if (_aa10+_ac10)> 0 then _se = _aa10/(_aa10+_ac10); else _se = 0; if (_ab10+_ad10)> 0 then _sp = 1-(_ad10/(_ab10+_ad10)); else _sp = 0; _lvlord = 'A'; output;
if (_aa05+_ac05)> 0 then _se = _aa05/(_aa05+_ac05); else _se = 0; if (_ab05+_ad05)> 0 then _sp = 1-(_ad05/(_ab05+_ad05)); else _sp = 0; _lvlord = 'A'; output;
_se=1; _sp=1; _lvlord = 'A'; output; if (_ba99+_bc99)> 0 then _se = _ba99/(_ba99+_bc99); else _se = 0; if (_bb99+_bd99)> 0 then _sp = 1-(_bd99/(_bb99+_bd99)); else _sp = 0; _lvlord = 'B'; output;
if (_ba95+_bc95)> 0 then _se = _ba95/(_ba95+_bc95); else _se = 0; if (_bb95+_bd95)> 0 then _sp = 1-(_bd95/(_bb95+_bd95)); else _sp = 0; _lvlord = 'B'; output;
if (_ba90+_bc90)> 0 then _se = _ba90/(_ba90+_bc90); else _se = 0; if (_bb90+_bd90)> 0 then _sp = 1-(_bd90/(_bb90+_bd90)); else _sp = 0; _lvlord = 'B'; output;
if (_ba85+_bc85)> 0 then _se = _ba85/(_ba85+_bc85); else _se = 0; if (_bb85+_bd85)> 0 then _sp = 1-(_bd85/(_bb85+_bd85)); else _sp = 0; _lvlord = 'B'; output;
if (_ba80+_bc80)> 0 then _se = _ba80/(_ba80+_bc80); else _se = 0; if (_bb80+_bd80)> 0 then _sp = 1-(_bd80/(_bb80+_bd80)); else _sp = 0; _lvlord = 'B'; output;
if (_ba75+_bc75)> 0 then _se = _ba75/(_ba75+_bc75); else _se = 0; if (_bb75+_bd75)> 0 then _sp = 1-(_bd75/(_bb75+_bd75)); else _sp = 0; _lvlord = 'B'; output;
if (_ba70+_bc70)> 0 then _se = _ba70/(_ba70+_bc70); else _se = 0; if (_bb70+_bd70)> 0 then _sp = 1-(_bd70/(_bb70+_bd70)); else _sp = 0; _lvlord = 'B'; output;
if (_ba65+_bc65)> 0 then _se = _ba65/(_ba65+_bc65); else _se = 0; if (_bb65+_bd65)> 0 then _sp = 1-(_bd65/(_bb65+_bd65)); else _sp = 0; _lvlord = 'B'; output;
if (_ba60+_bc60)> 0 then _se = _ba60/(_ba60+_bc60); else _se = 0; if (_bb60+_bd60)> 0 then _sp = 1-(_bd60/(_bb60+_bd60)); else _sp = 0; _lvlord = 'B'; output;
if (_ba55+_bc55)> 0 then _se = _ba55/(_ba55+_bc55); else _se = 0; if (_bb55+_bd55)> 0 then _sp = 1-(_bd55/(_bb55+_bd55)); else _sp = 0; _lvlord = 'B'; output;
if (_ba50+_bc50)> 0 then _se = _ba50/(_ba50+_bc50); else _se = 0; if (_bb50+_bd50)> 0 then _sp = 1-(_bd50/(_bb50+_bd50)); else _sp = 0; _lvlord = 'B'; output;
if (_ba45+_bc45)> 0 then _se = _ba45/(_ba45+_bc45); else _se = 0; if (_bb45+_bd45)> 0 then _sp = 1-(_bd45/(_bb45+_bd45)); else _sp = 0; _lvlord = 'B'; output;
if (_ba40+_bc40)> 0 then _se = _ba40/(_ba40+_bc40); else _se = 0; if (_bb40+_bd40)> 0 then _sp = 1-(_bd40/(_bb40+_bd40)); else _sp = 0; _lvlord = 'B'; output;
if (_ba35+_bc35)> 0 then _se = _ba35/(_ba35+_bc35); else _se = 0; if (_bb35+_bd35)> 0 then _sp = 1-(_bd35/(_bb35+_bd35)); else _sp = 0; _lvlord = 'B'; output;
if (_ba30+_bc30)> 0 then _se = _ba30/(_ba30+_bc30); else _se = 0; if (_bb30+_bd30)> 0 then _sp = 1-(_bd30/(_bb30+_bd30)); else _sp = 0; _lvlord = 'B'; output;
if (_ba25+_bc25)> 0 then _se = _ba25/(_ba25+_bc25); else _se = 0; if (_bb25+_bd25)> 0 then _sp = 1-(_bd25/(_bb25+_bd25)); else _sp = 0; _lvlord = 'B'; output;
if (_ba20+_bc20)> 0 then _se = _ba20/(_ba20+_bc20); else _se = 0; if (_bb20+_bd20)> 0 then _sp = 1-(_bd20/(_bb20+_bd20)); else _sp = 0; _lvlord = 'B'; output;
if (_ba15+_bc15)> 0 then _se = _ba15/(_ba15+_bc15); else _se = 0; if (_bb15+_bd15)> 0 then _sp = 1-(_bd15/(_bb15+_bd15)); else _sp = 0; _lvlord = 'B'; output;
if (_ba10+_bc10)> 0 then _se = _ba10/(_ba10+_bc10); else _se = 0; if (_bb10+_bd10)> 0 then _sp = 1-(_bd10/(_bb10+_bd10)); else _sp = 0; _lvlord = 'B'; output;
if (_ba05+_bc05)> 0 then _se = _ba05/(_ba05+_bc05); else _se = 0; if (_bb05+_bd05)> 0 then _sp = 1-(_bd05/(_bb05+_bd05)); else _sp = 0; _lvlord = 'B'; output;
_se=1; _sp=1; _lvlord = 'B'; output; /* replaced by the line above if (_ba00+_bc00)> 0 then _se = _ba00/(_ba00+_bc00); else _se = 0; if (_bb00+_bd00)> 0 then _sp = 1-(_bd00/(_bb00+_bd00)); else _sp = 0; _lvlord = 'B'; output; */ end; run;
proc sql; create view EMPROJ._000srv as select * from EMPROJ._000sroc where lvlord = "A"; quit;
proc sql; create view EMPROJ._000srv as select * from EMPROJ._000sroc where lvlord = "B"; quit;
data EMPROJ._A000037; set EMPROJ._000sroc; if _n_ = 1 then do; sp = 0; se = 0.77444589308996; lvlord = 'A'; output; sp = 0.1; se = 1; lvlord = 'A'; output; sp = 0.2; se = 1; lvlord = 'A'; output; sp = 0.3; se = 1; lvlord = 'A'; output; sp = 0.4; se = 1; lvlord = 'A'; output; sp = 0.5; se = 1; lvlord = 'A'; output; sp = 0.6; se = 1; lvlord = 'A'; output; sp = 0.7; se = 1; lvlord = 'A'; output; sp = 0.8; se = 1; lvlord = 'A'; output; sp = 0.9; se = 1; lvlord = 'A'; output; sp = 1; se = 1; lvlord = 'A'; output; sp = 0; se = 0; lvlord = 'B'; output; sp = 0.1; se = 1; lvlord = 'B'; output; sp = 0.2; se = 1; lvlord = 'B'; output; sp = 0.3; se = 1; lvlord = 'B'; output; sp = 0.4; se = 1; lvlord = 'B'; output; sp = 0.5; se = 1; lvlord = 'B'; output; sp = 0.6; se = 1; lvlord = 'B'; output; sp = 0.7; se = 1; lvlord = 'B'; output; sp = 0.8; se = 1; lvlord = 'B'; output; sp = 0.9; se = 1; lvlord = 'B'; output; sp = 1; se = 1; lvlord = 'B'; output; stop; end; run;
data EMPROJ._A000038(keep=_tool _thresh _freq _lvlord _predict _actual rename=(_thresh=thresh _predict=predict _actual=actual _freq=freq _tool=tool _lvlord=lvlord)); set EMPROJ._A00003A end=last_obn; length _tool $15 _lvlord $1 _predict _actual $%DMNORLEN _freq _thresh 8 _Ftarget $%DMNORLEN; drop _Ftarget; retain _aa99 _ab99 _ac99 _ad99 _aa95 _ab95 _ac95 _ad95 _aa90 _ab90 _ac90 _ad90 _aa85 _ab85 _ac85 _ad85 _aa80 _ab80 _ac80 _ad80 _aa75 _ab75 _ac75 _ad75 _aa70 _ab70 _ac70 _ad70 _aa65 _ab65 _ac65 _ad65 _aa60 _ab60 _ac60 _ad60 _aa55 _ab55 _ac55 _ad55 _aa50 _ab50 _ac50 _ad50 _aa45 _ab45 _ac45 _ad45 _aa40 _ab40 _ac40 _ad40 _aa35 _ab35 _ac35 _ad35 _aa30 _ab30 _ac30 _ad30 _aa25 _ab25 _ac25 _ad25 _aa20 _ab20 _ac20 _ad20 _aa15 _ab15 _ac15 _ad15 _aa10 _ab10 _ac10 _ad10 _aa05 _ab05 _ac05 _ad05 _aa00 _ab00 _ac00 _ad00 _ba99 _bb99 _bc99 _bd99 _ba95 _bb95 _bc95 _bd95 _ba90 _bb90 _bc90 _bd90 _ba85 _bb85 _bc85 _bd85 _ba80 _bb80 _bc80 _bd80 _ba75 _bb75 _bc75 _bd75 _ba70 _bb70 _bc70 _bd70 _ba65 _bb65 _bc65 _bd65 _ba60 _bb60 _bc60 _bd60 _ba55 _bb55 _bc55 _bd55 _ba50 _bb50 _bc50 _bd50 _ba45 _bb45 _bc45 _bd45 _ba40 _bb40 _bc40 _bd40 _ba35 _bb35 _bc35 _bd35 _ba30 _bb30 _bc30 _bd30 _ba25 _bb25 _bc25 _bd25 _ba20 _bb20 _bc20 _bd20 _ba15 _bb15 _bc15 _bd15 _ba10 _bb10 _bc10 _bd10 _ba05 _bb05 _bc05 _bd05 _ba00 _bb00 _bc00 _bd00 0 ;
_tool = "Regression"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if P_RESPOND1 = 1 then do; if _Ftarget = '1' then _aa99 = _aa99 + 1; else _ab99 = _ab99 + 1; end; else do; if _Ftarget = '1' then _ac99 = _ac99 + 1; else _ad99 = _ad99 + 1; end;
if P_RESPOND1 >= .95 then do; if _Ftarget = '1' then _aa95 = _aa95 + 1; else _ab95 = _ab95 + 1; end; else do; if _Ftarget = '1' then _ac95 = _ac95 + 1; else _ad95 = _ad95 + 1; end;
if P_RESPOND1 >= .90 then do; if _Ftarget = '1' then _aa90 = _aa90 + 1; else _ab90 = _ab90 + 1; end; else do; if _Ftarget = '1' then _ac90 = _ac90 + 1; else _ad90 = _ad90 + 1; end;
if P_RESPOND1 >= .85 then do; if _Ftarget = '1' then _aa85 = _aa85 + 1; else _ab85 = _ab85 + 1; end; else do; if _Ftarget = '1' then _ac85 = _ac85 + 1; else _ad85 = _ad85 + 1; end;
if P_RESPOND1 >= .80 then do; if _Ftarget = '1' then _aa80 = _aa80 + 1; else _ab80 = _ab80 + 1; end; else do; if _Ftarget = '1' then _ac80 = _ac80 + 1; else _ad80 = _ad80 + 1; end;
if P_RESPOND1 >= .75 then do; if _Ftarget = '1' then _aa75 = _aa75 + 1; else _ab75 = _ab75 + 1; end; else do; if _Ftarget = '1' then _ac75 = _ac75 + 1; else _ad75 = _ad75 + 1; end;
if P_RESPOND1 >= .70 then do; if _Ftarget = '1' then _aa70 = _aa70 + 1; else _ab70 = _ab70 + 1; end; else do; if _Ftarget = '1' then _ac70 = _ac70 + 1; else _ad70 = _ad70 + 1; end;
if P_RESPOND1 >= .65 then do; if _Ftarget = '1' then _aa65 = _aa65 + 1; else _ab65 = _ab65 + 1; end; else do; if _Ftarget = '1' then _ac65 = _ac65 + 1; else _ad65 = _ad65 + 1; end;
if P_RESPOND1 >= .60 then do; if _Ftarget = '1' then _aa60 = _aa60 + 1; else _ab60 = _ab60 + 1; end; else do; if _Ftarget = '1' then _ac60 = _ac60 + 1; else _ad60 = _ad60 + 1; end;
if P_RESPOND1 >= .55 then do; if _Ftarget = '1' then _aa55 = _aa55 + 1; else _ab55 = _ab55 + 1; end; else do; if _Ftarget = '1' then _ac55 = _ac55 + 1; else _ad55 = _ad55 + 1; end;
if P_RESPOND1 >= .50 then do; if _Ftarget = '1' then _aa50 = _aa50 + 1; else _ab50 = _ab50 + 1; end; else do; if _Ftarget = '1' then _ac50 = _ac50 + 1; else _ad50 = _ad50 + 1; end;
if P_RESPOND1 >= .45 then do; if _Ftarget = '1' then _aa45 = _aa45 + 1; else _ab45 = _ab45 + 1; end; else do; if _Ftarget = '1' then _ac45 = _ac45 + 1; else _ad45 = _ad45 + 1; end;
if P_RESPOND1 >= .40 then do; if _Ftarget = '1' then _aa40 = _aa40 + 1; else _ab40 = _ab40 + 1; end; else do; if _Ftarget = '1' then _ac40 = _ac40 + 1; else _ad40 = _ad40 + 1; end;
if P_RESPOND1 >= .35 then do; if _Ftarget = '1' then _aa35 = _aa35 + 1; else _ab35 = _ab35 + 1; end; else do; if _Ftarget = '1' then _ac35 = _ac35 + 1; else _ad35 = _ad35 + 1; end;
if P_RESPOND1 >= .30 then do; if _Ftarget = '1' then _aa30 = _aa30 + 1; else _ab30 = _ab30 + 1; end; else do; if _Ftarget = '1' then _ac30 = _ac30 + 1; else _ad30 = _ad30 + 1; end;
if P_RESPOND1 >= .25 then do; if _Ftarget = '1' then _aa25 = _aa25 + 1; else _ab25 = _ab25 + 1; end; else do; if _Ftarget = '1' then _ac25 = _ac25 + 1; else _ad25 = _ad25 + 1; end;
if P_RESPOND1 >= .20 then do; if _Ftarget = '1' then _aa20 = _aa20 + 1; else _ab20 = _ab20 + 1; end; else do; if _Ftarget = '1' then _ac20 = _ac20 + 1; else _ad20 = _ad20 + 1; end;
if P_RESPOND1 >= .15 then do; if _Ftarget = '1' then _aa15 = _aa15 + 1; else _ab15 = _ab15 + 1; end; else do; if _Ftarget = '1' then _ac15 = _ac15 + 1; else _ad15 = _ad15 + 1; end;
if P_RESPOND1 >= .10 then do; if _Ftarget = '1' then _aa10 = _aa10 + 1; else _ab10 = _ab10 + 1; end; else do; if _Ftarget = '1' then _ac10 = _ac10 + 1; else _ad10 = _ad10 + 1; end;
if P_RESPOND1 >= .05 then do; if _Ftarget = '1' then _aa05 = _aa05 + 1; else _ab05 = _ab05 + 1; end; else do; if _Ftarget = '1' then _ac05 = _ac05 + 1; else _ad05 = _ad05 + 1; end;
if P_RESPOND1 >= 0 then do; if _Ftarget = '1' then _aa00 = _aa00 + 1; else _ab00 = _ab00 + 1; end; else do; if _Ftarget = '1' then _ac00 = _ac00 + 1; else _ad00 = _ad00 + 1; end; /* process target level 2 */ if P_RESPOND0 = 1 then do; if _Ftarget = '0' then _ba99 = _ba99 + 1; else _bb99 = _bb99 + 1; end; else do; if _Ftarget = '0' then _bc99 = _bc99 + 1; else _bd99 = _bd99 + 1; end;
if P_RESPOND0 >= .95 then do; if _Ftarget = '0' then _ba95 = _ba95 + 1; else _bb95 = _bb95 + 1; end; else do; if _Ftarget = '0' then _bc95 = _bc95 + 1; else _bd95 = _bd95 + 1; end;
if P_RESPOND0 >= .90 then do; if _Ftarget = '0' then _ba90 = _ba90 + 1; else _bb90 = _bb90 + 1; end; else do; if _Ftarget = '0' then _bc90 = _bc90 + 1; else _bd90 = _bd90 + 1; end;
if P_RESPOND0 >= .85 then do; if _Ftarget = '0' then _ba85 = _ba85 + 1; else _bb85 = _bb85 + 1; end; else do; if _Ftarget = '0' then _bc85 = _bc85 + 1; else _bd85 = _bd85 + 1; end;
if P_RESPOND0 >= .80 then do; if _Ftarget = '0' then _ba80 = _ba80 + 1; else _bb80 = _bb80 + 1; end; else do; if _Ftarget = '0' then _bc80 = _bc80 + 1; else _bd80 = _bd80 + 1; end;
if P_RESPOND0 >= .75 then do; if _Ftarget = '0' then _ba75 = _ba75 + 1; else _bb75 = _bb75 + 1; end; else do; if _Ftarget = '0' then _bc75 = _bc75 + 1; else _bd75 = _bd75 + 1; end;
if P_RESPOND0 >= .70 then do; if _Ftarget = '0' then _ba70 = _ba70 + 1; else _bb70 = _bb70 + 1; end; else do; if _Ftarget = '0' then _bc70 = _bc70 + 1; else _bd70 = _bd70 + 1; end;
if P_RESPOND0 >= .65 then do; if _Ftarget = '0' then _ba65 = _ba65 + 1; else _bb65 = _bb65 + 1; end; else do; if _Ftarget = '0' then _bc65 = _bc65 + 1; else _bd65 = _bd65 + 1; end;
if P_RESPOND0 >= .60 then do; if _Ftarget = '0' then _ba60 = _ba60 + 1; else _bb60 = _bb60 + 1; end; else do; if _Ftarget = '0' then _bc60 = _bc60 + 1; else _bd60 = _bd60 + 1; end;
if P_RESPOND0 >= .55 then do; if _Ftarget = '0' then _ba55 = _ba55 + 1; else _bb55 = _bb55 + 1; end; else do; if _Ftarget = '0' then _bc55 = _bc55 + 1; else _bd55 = _bd55 + 1; end;
if P_RESPOND0 >= .50 then do; if _Ftarget = '0' then _ba50 = _ba50 + 1; else _bb50 = _bb50 + 1; end; else do; if _Ftarget = '0' then _bc50 = _bc50 + 1; else _bd50 = _bd50 + 1; end;
if P_RESPOND0 >= .45 then do; if _Ftarget = '0' then _ba45 = _ba45 + 1; else _bb45 = _bb45 + 1; end; else do; if _Ftarget = '0' then _bc45 = _bc45 + 1; else _bd45 = _bd45 + 1; end;
if P_RESPOND0 >= .40 then do; if _Ftarget = '0' then _ba40 = _ba40 + 1; else _bb40 = _bb40 + 1; end; else do; if _Ftarget = '0' then _bc40 = _bc40 + 1; else _bd40 = _bd40 + 1; end;
if P_RESPOND0 >= .35 then do; if _Ftarget = '0' then _ba35 = _ba35 + 1; else _bb35 = _bb35 + 1; end; else do; if _Ftarget = '0' then _bc35 = _bc35 + 1; else _bd35 = _bd35 + 1; end;
if P_RESPOND0 >= .30 then do; if _Ftarget = '0' then _ba30 = _ba30 + 1; else _bb30 = _bb30 + 1; end; else do; if _Ftarget = '0' then _bc30 = _bc30 + 1; else _bd30 = _bd30 + 1; end;
if P_RESPOND0 >= .25 then do; if _Ftarget = '0' then _ba25 = _ba25 + 1; else _bb25 = _bb25 + 1; end; else do; if _Ftarget = '0' then _bc25 = _bc25 + 1; else _bd25 = _bd25 + 1; end;
if P_RESPOND0 >= .20 then do; if _Ftarget = '0' then _ba20 = _ba20 + 1; else _bb20 = _bb20 + 1; end; else do; if _Ftarget = '0' then _bc20 = _bc20 + 1; else _bd20 = _bd20 + 1; end;
if P_RESPOND0 >= .15 then do; if _Ftarget = '0' then _ba15 = _ba15 + 1; else _bb15 = _bb15 + 1; end; else do; if _Ftarget = '0' then _bc15 = _bc15 + 1; else _bd15 = _bd15 + 1; end;
if P_RESPOND0 >= .10 then do; if _Ftarget = '0' then _ba10 = _ba10 + 1; else _bb10 = _bb10 + 1; end; else do; if _Ftarget = '0' then _bc10 = _bc10 + 1; else _bd10 = _bd10 + 1; end;
if P_RESPOND0 >= .05 then do; if _Ftarget = '0' then _ba05 = _ba05 + 1; else _bb05 = _bb05 + 1; end; else do; if _Ftarget = '0' then _bc05 = _bc05 + 1; else _bd05 = _bd05 + 1; end;
if P_RESPOND0 >= 0 then do; if _Ftarget = '0' then _ba00 = _ba00 + 1; else _bb00 = _bb00 + 1; end; else do; if _Ftarget = '0' then _bc00 = _bc00 + 1; else _bd00 = _bd00 + 1; end; if last_obn then do; _thresh=100;_lvlord='A'; _actual='1'; _predict='1'; _freq=_aa99; output; _actual='1'; _predict='0'; _freq=_ac99; output; _actual='0'; _predict='1'; _freq=_ab99; output; _actual='0'; _predict='0'; _freq=_ad99; output;
_thresh=95; _actual='1'; _predict='1'; _freq=_aa95; output; _actual='1'; _predict='0'; _freq=_ac95; output; _actual='0'; _predict='1'; _freq=_ab95; output; _actual='0'; _predict='0'; _freq=_ad95; output;
_thresh=90; _actual='1'; _predict='1'; _freq=_aa90; output; _actual='1'; _predict='0'; _freq=_ac90; output; _actual='0'; _predict='1'; _freq=_ab90; output; _actual='0'; _predict='0'; _freq=_ad90; output;
_thresh=85; _actual='1'; _predict='1'; _freq=_aa85; output; _actual='1'; _predict='0'; _freq=_ac85; output; _actual='0'; _predict='1'; _freq=_ab85; output; _actual='0'; _predict='0'; _freq=_ad85; output;
_thresh=80; _actual='1'; _predict='1'; _freq=_aa80; output; _actual='1'; _predict='0'; _freq=_ac80; output; _actual='0'; _predict='1'; _freq=_ab80; output; _actual='0'; _predict='0'; _freq=_ad80; output;
_thresh=75; _actual='1'; _predict='1'; _freq=_aa75; output; _actual='1'; _predict='0'; _freq=_ac75; output; _actual='0'; _predict='1'; _freq=_ab75; output; _actual='0'; _predict='0'; _freq=_ad75; output;
_thresh=70; _actual='1'; _predict='1'; _freq=_aa70; output; _actual='1'; _predict='0'; _freq=_ac70; output; _actual='0'; _predict='1'; _freq=_ab70; output; _actual='0'; _predict='0'; _freq=_ad70; output;
_thresh=65; _actual='1'; _predict='1'; _freq=_aa65; output; _actual='1'; _predict='0'; _freq=_ac65; output; _actual='0'; _predict='1'; _freq=_ab65; output; _actual='0'; _predict='0';_freq=_ad65; output;
_thresh=60; _actual='1'; _predict='1'; _freq=_aa60; output; _actual='1'; _predict='0'; _freq=_ac60; output; _actual='0'; _predict='1'; _freq=_ab60; output; _actual='0'; _predict='0';_freq=_ad60; output;
_thresh=55; _actual='1'; _predict='1'; _freq=_aa55; output; _actual='1'; _predict='0'; _freq=_ac55; output; _actual='0'; _predict='1'; _freq=_ab55; output; _actual='0'; _predict='0'; _freq=_ad55; output;
_thresh=50; _actual='1'; _predict='1'; _freq=_aa50; output; _actual='1'; _predict='0'; _freq=_ac50; output; _actual='0'; _predict='1'; _freq=_ab50; output; _actual='0'; _predict='0'; _freq=_ad50; output;
_thresh=45; _actual='1'; _predict='1'; _freq=_aa45; output; _actual='1'; _predict='0'; _freq=_ac45; output; _actual='0'; _predict='1'; _freq=_ab45; output; _actual='0'; _predict='0'; _freq=_ad45; output;
_thresh=40; _actual='1'; _predict='1'; _freq=_aa40; output; _actual='1'; _predict='0'; _freq=_ac40; output; _actual='0'; _predict='1'; _freq=_ab40; output; _actual='0'; _predict='0'; _freq=_ad40; output;
_thresh=35; _actual='1'; _predict='1'; _freq=_aa35; output; _actual='1'; _predict='0'; _freq=_ac35; output; _actual='0'; _predict='1'; _freq=_ab35; output; _actual='0'; _predict='0'; _freq=_ad35; output;
_thresh=30; _actual='1'; _predict='1'; _freq=_aa30; output; _actual='1'; _predict='0'; _freq=_ac30; output; _actual='0'; _predict='1'; _freq=_ab30; output; _actual='0'; _predict='0'; _freq=_ad30; output;
_thresh=25; _actual='1'; _predict='1'; _freq=_aa25; output; _actual='1'; _predict='0'; _freq=_ac25; output; _actual='0'; _predict='1'; _freq=_ab25; output; _actual='0'; _predict='0'; _freq=_ad25; output;
_thresh=20; _actual='1'; _predict='1'; _freq=_aa20; output; _actual='1'; _predict='0'; _freq=_ac20; output; _actual='0'; _predict='1'; _freq=_ab20; output; _actual='0'; _predict='0'; _freq=_ad20; output;
_thresh=15; _actual='1'; _predict='1'; _freq=_aa15; output; _actual='1'; _predict='0'; _freq=_ac15; output; _actual='0'; _predict='1'; _freq=_ab15; output; _actual='0'; _predict='0'; _freq=_ad15; output;
_thresh=10; _actual='1'; _predict='1'; _freq=_aa10; output; _actual='1'; _predict='0'; _freq=_ac10; output; _actual='0'; _predict='1'; _freq=_ab10; output; _actual='0'; _predict='0'; _freq=_ad10; output;
_thresh= 5; _actual='1'; _predict='1'; _freq=_aa05; output; _actual='1'; _predict='0'; _freq=_ac05; output; _actual='0'; _predict='1'; _freq=_ab05; output; _actual='0'; _predict='0'; _freq=_ad05; output;
_thresh= 0; _actual='1'; _predict='1'; _freq=_aa00; output; _actual='1'; _predict='0'; _freq=_ac00; output; _actual='0'; _predict='1'; _freq=_ab00; output; _actual='0'; _predict='0'; _freq=_ad00; output; _thresh=100;_lvlord='B'; _actual='1'; _predict='1'; _freq=_bd99; output; _actual='1'; _predict='0'; _freq=_bb99; output; _actual='0'; _predict='1'; _freq=_bc99; output; _actual='0'; _predict='0'; _freq=_ba99; output;
_thresh=95; _actual='1'; _predict='1'; _freq=_bd95; output; _actual='1'; _predict='0'; _freq=_bb95; output; _actual='0'; _predict='1'; _freq=_bc95; output; _actual='0'; _predict='0'; _freq=_ba95; output;
_thresh=90; _actual='1'; _predict='1'; _freq=_bd90; output; _actual='1'; _predict='0'; _freq=_bb90; output; _actual='0'; _predict='1'; _freq=_bc90; output; _actual='0'; _predict='0'; _freq=_ba90; output;
_thresh=85; _actual='1'; _predict='1'; _freq=_bd85; output; _actual='1'; _predict='0'; _freq=_bb85; output; _actual='0'; _predict='1'; _freq=_bc85; output; _actual='0'; _predict='0'; _freq=_ba85; output;
_thresh=80; _actual='1'; _predict='1'; _freq=_bd80; output; _actual='1'; _predict='0'; _freq=_bb80; output; _actual='0'; _predict='1'; _freq=_bc80; output; _actual='0'; _predict='0'; _freq=_ba80; output;
_thresh=75; _actual='1'; _predict='1'; _freq=_bd75; output; _actual='1'; _predict='0'; _freq=_bb75; output; _actual='0'; _predict='1'; _freq=_bc75; output; _actual='0'; _predict='0'; _freq=_ba75; output;
_thresh=70; _actual='1'; _predict='1'; _freq=_bd70; output; _actual='1'; _predict='0'; _freq=_bb70; output; _actual='0'; _predict='1'; _freq=_bc70; output; _actual='0'; _predict='0'; _freq=_ba70; output;
_thresh=65; _actual='1'; _predict='1'; _freq=_bd65; output; _actual='1'; _predict='0'; _freq=_bb65; output; _actual='0'; _predict='1'; _freq=_bc65; output; _actual='0'; _predict='0'; _freq=_ba65; output;
_thresh=60; _actual='1'; _predict='1'; _freq=_bd60; output; _actual='1'; _predict='0'; _freq=_bb60; output; _actual='0'; _predict='1'; _freq=_bc60; output; _actual='0'; _predict='0'; _freq=_ba60; output;
_thresh=55; _actual='1'; _predict='1'; _freq=_bd55; output; _actual='1'; _predict='0'; _freq=_bb55; output; _actual='0'; _predict='1'; _freq=_bc55; output; _actual='0'; _predict='0'; _freq=_ba55; output;
_thresh=50; _actual='1'; _predict='1'; _freq=_bd50; output; _actual='1'; _predict='0'; _freq=_bb50; output; _actual='0'; _predict='1'; _freq=_bc50; output; _actual='0'; _predict='0'; _freq=_ba50; output;
_thresh=45; _actual='1'; _predict='1'; _freq=_bd45; output; _actual='1'; _predict='0'; _freq=_bb45; output; _actual='0'; _predict='1'; _freq=_bc45; output; _actual='0'; _predict='0'; _freq=_ba45; output;
_thresh=40; _actual='1'; _predict='1'; _freq=_bd40; output; _actual='1'; _predict='0'; _freq=_bb40; output; _actual='0'; _predict='1'; _freq=_bc40; output; _actual='0'; _predict='0'; _freq=_ba40; output;
_thresh=35; _actual='1'; _predict='1'; _freq=_bd35; output; _actual='1'; _predict='0'; _freq=_bb35; output; _actual='0'; _predict='1'; _freq=_bc35; output; _actual='0'; _predict='0'; _freq=_ba35; output;
_thresh=30; _actual='1'; _predict='1'; _freq=_bd30; output; _actual='1'; _predict='0'; _freq=_bb30; output; _actual='0'; _predict='1'; _freq=_bc30; output; _actual='0'; _predict='0'; _freq=_ba30; output;
_thresh=25; _actual='1'; _predict='1'; _freq=_bd25; output; _actual='1'; _predict='0'; _freq=_bb25; output; _actual='0'; _predict='1'; _freq=_bc25; output; _actual='0'; _predict='0'; _freq=_ba25; output;
_thresh=20; _actual='1'; _predict='1'; _freq=_bd20; output; _actual='1'; _predict='0'; _freq=_bb20; output; _actual='0'; _predict='1'; _freq=_bc20; output; _actual='0'; _predict='0'; _freq=_ba20; output;
_thresh=15; _actual='1'; _predict='1'; _freq=_bd15; output; _actual='1'; _predict='0'; _freq=_bb15; output; _actual='0'; _predict='1'; _freq=_bc15; output; _actual='0'; _predict='0'; _freq=_ba15; output;
_thresh=10; _actual='1'; _predict='1'; _freq=_bd10; output; _actual='1'; _predict='0'; _freq=_bb10; output; _actual='0'; _predict='1'; _freq=_bc10; output; _actual='0'; _predict='0'; _freq=_ba10; output;
_thresh= 5; _actual='1'; _predict='1'; _freq=_bd05; output; _actual='1'; _predict='0'; _freq=_bb05; output; _actual='0'; _predict='1'; _freq=_bc05; output; _actual='0'; _predict='0'; _freq=_ba05; output;
_thresh= 0; _actual='1'; _predict='1'; _freq=_bd00; output; _actual='1'; _predict='0'; _freq=_bb00; output; _actual='0'; _predict='1'; _freq=_bc00; output; _actual='0'; _predict='0'; _freq=_ba00; output; end; run; |
3. TREE MODEL | |
|
%let _tmp=%DMNORLEN; proc dmdb data=EMDATA.VIEW_IXA out=_null_ dmdbcat=EMPROJ.dm_DGM00000 normlen=32 maxlevel=513; class BUY12(Asc) BUY18(Asc) BUY6(Asc) CLIMATE(Asc) COA6(Asc) DISCBUY(Asc) LOC(Asc) MARRIED(Asc) ORGSRC(Asc) OWNHOME(Asc) RETURN24(Asc) SEX(Asc) RESPOND(Desc); var AGE C1 C2 C3 C4 C5 C6 C7 FICO INCOME PURCHTOT VALUE24; target RESPOND; run;
* Create data view with dmdb name; data EMDATA.dm_DGM00000 / view=EMDATA.dm_DGM00000; set EMDATA.VIEW_IXA; run;
* TREE모형 실행; proc split data = emdata.dm_DGM00000 outtree= EMPROJ.TREEI1ZD nodesample=10000 /* NODESAMPLE - 관측치개수(treei1zd:NOBS TRAIN)*/ splitsize =41 /* NODESAMPLE/100 */ leafsize =10 /* MINSIZE(treei1zd: x변수)*/ NRULES =5 /* MAXSPLITS(treei1zd: x변수)*/ OUTAFDS = afdsdata OUTIMPORTANCE=IMPORTANCEdata OUTLEAF = leafdata OUTMATRIX = matrixdata /* SUMMARY DATA */ OUTSEQ = subtree; input SEX MARRIED BUY12 OWNHOME LOC CLIMATE ORGSRC DISCBUY RETURN24 COA6 BUY6 BUY18 /level=nominal; input AGE INCOME FICO VALUE24 C1 C2 C3 C4 C5 C6 C7 PURCHTOT /level=interval; target RESPOND/level=binary; run;
proc split intree = EMPROJ.TREEI1ZD data = emdata.dm_DGM00000 outtree = EMPROJ.TREEO80B; run;
proc sql; reset noprint; create view EMPROJ.SMP_TRR0 as select * from EMPROJ.TREEO80B; quit;
proc split intree = EMPROJ.TREEO80B; score data = EMDATA.VIEW_IXA out = EMPROJ._A00000G(keep=P_: D_: ID _WARN_ EP_: BP_: CP_: EL_: BL_: CL_: IC_: RESPOND) outfit = EMPROJ.TNFTYW0K role = TRAIN; run;
data EMPROJ.RESPOND_(type=PROFIT label=RESPOND); LENGTH RESPOND $%DMNORLEN; input RESPOND $1-%DMNORLEN _MPRIOR _DEC1 @; label _DEC1="1"; cards; 1 0.0767 1 0 0.9233 0 ; run; quit;
data work._DECDBG_; set EMPROJ.RESPOND_; run; quit; proc decide data=EMPROJ._A00000G out=EMPROJ._A00000G; target RESPOND; posterior P_RESPOND1 P_RESPOND0; decision decisiondata= EMPROJ.RESPOND_ decvars=_DEC1; code residuals; run; quit;
data EMPROJ._000tran(keep=_cost _aprofit _e_prob _e_count) EMPROJ._A000004(keep=_nprofit _nobs _pmiss) EMPROJ._A00000H(keep= RESPOND P_RESPOND1 P_RESPOND0 EP_RESPOND_ BP_RESPOND_ CP_RESPOND_ _eprofit _cost _aprofit _warn_ _e_count _e_prob); set EMPROJ._A00000G end=_lastobn; length _aprofit 8 _Ftarget $%DMNORLEN; _cost = 0; _eprofit = EP_RESPOND_; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.)))); if (_Ftarget = '' or _Ftarget = '.') and (NOT _lastobn) then delete; _e_prob = P_RESPOND1; if _Ftarget = '1' then do; _e_count = 1; end; else if _Ftarget = '0' then do; _e_count = 0; end; _aprofit = CP_RESPOND_; _ncount + 1; output EMPROJ._000tran EMPROJ._A00000H; if _e_count > 0 then _nprofit + 1; if _eprofit = . then _pmiss + 1; if _lastobn then do; _nobs = _ncount; _pmiss = _pmiss/_n_; put _pmiss= _nobs= _nprofit=; output EMPROJ._A000004; end; run;
data EMPROJ._A00000I; set EMPROJ._A00000H; drop _eprofit _cost _aprofit _freq_ _freqadj _e_: ic_: ep_: bp_: cp_: el_: bl_: cl_: ; drop _c000000; if _c000000 < 5000 then do; if ( (10000-_N_) * ranuni(12345) ) <= (5000-_c000000) then do; _c000000+1; output; end; end; run;
proc sort data=EMPROJ._A00000H ; by descending _e_prob; run;
* LIFT VALUE값 생성; data EMPROJ._A000002(keep= _tool_ _decile _cutoff _eprofit _cap _lift _resp _capc _liftc _respc _gcount version); set EMPROJ._A00000H end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7;
retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _resp9 _respc9 _cap9 _capc9 _lift9 _liftc9; rename _e_prob = _cutoff; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Tree"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _e_prob) < 1E-7 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_p = _e_prob; _tgcount = _tgcount + 1; if _e_count > 0 then do; _tcount = _tcount + 1; end; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; end; else do; _ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do;
do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end;
_count = _gcount * _ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; end; else do; _tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; link do_out; end;
_ave = _tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0;
_tcount = _tgcount * _tave; end; return;
do_out: _nobns = _nobns + _n_per_q;
_q_out = _q_out + 1; _decile = 100 * _q_out / nquants; _cap = _n_per_q * _ave * 100 / n_y_1; _lift = _ave / ( n_y_1 / sumfreq); _resp = _ave * 100;
_countc = _countc + _n_per_q * _ave; _capc = (_countc / n_y_1) * 100; _liftc = _capc / _decile; _respc = (_countc / _nobns) * 100; if ^_lastobs then _eprofit = _prev_ep; if _q_out > 1 then do; if abs(_resp - _resp9 ) < 1E-7 then _resp = _resp9 ; if abs(_respc - _respc9 ) < 1E-7 then _respc = _respc9 ; if abs(_cap - _cap9 ) < 1E-7 then _cap = _cap9 ; if abs(_capc - _capc9 ) < 1E-7 then _capc = _capc9 ; if abs(_lift - _lift9 ) < 1E-7 then _lift = _lift9 ; if abs(_liftc - _liftc9 ) < 1E-7 then _liftc = _liftc9 ; end; if _q_out = 1 then do; _respc = _resp; _capc = _cap; _liftc = _lift; end; if ^_lastobs then _e_prob = _prev_ep; output;
if _q_out = 1 then do; _resp9 = _resp; _respc9 = _respc; _cap9 = _cap; _capc9 = _capc; _lift9 = _lift; _liftc9 = _liftc; end; else do; if abs(_resp - _resp9 ) > 1E-7 then _resp9 = _resp ; if abs(_respc - _respc9 ) > 1E-7 then _respc9 = _respc ; if abs(_cap - _cap9 ) > 1E-7 then _cap9 = _cap ; if abs(_capc - _capc9 ) > 1E-7 then _capc9 = _capc ; if abs(_lift - _lift9 ) > 1E-7 then _lift9 = _lift ; if abs(_liftc - _liftc9 ) > 1E-7 then _liftc9 = _liftc ; end; return; run;
proc sort data=EMPROJ._A00000H ; by descending _eprofit; run;
* PROFIT값 생성; data EMPROJ._000LFT2(keep= _profit _roi _profitc _roic Tprofit Tprofitc proftype _iscost0); set EMPROJ._A00000H end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7;
retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _prev_ep 0; /* EP from previous observation. */ retain _prof2 0 _cost2 0 _tprof2 0 _tcost2 0; retain _profitc 0 _roic 0; retain _profit9 _proftc9 _roi9 _roic9; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Tree"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _eprofit) < 0.00001 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; _prof2 + _tprof2; _tprof2 = 0; _cost2 + _tcost2; _tcost2 = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_ep = _cur_ep; _eprofit = _cur_ep; _prev_p = _eprofit; _tgcount = _tgcount + 1; if _aprofit > 0.5 then do; _tcount = _tcount + 1; end; _tprof2 + _aprofit; _tcost2 + _cost; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; _p_ave = _prof2/_gcount; _c_ave = _cost2/_gcount; end; else do; _ave = 0; _p_ave = 0; _c_ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do;
do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end; _count = _gcount * _ave; _prof2 = _gcount * _p_ave; _cost2 = _gcount * _c_ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; _p_tave = _tprof2/_tgcount; _c_tave = _tcost2/_tgcount; end; else do; _tave = 0; _p_tave = 0; _c_tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _p_ave = (_gcount * _p_ave + (_n_per_q - _gcount) * _p_tave) / _n_per_q;
_c_ave = (_gcount * _c_ave + (_n_per_q - _gcount) * _c_tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; _prof2 = 0; _cost2 = 0; link do_out; end;
_ave = _tave; _p_ave = _p_tave; _c_ave = _c_tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0;
_tcount = _tgcount * _tave; _tprof2 = _tgcount * _p_tave; _tcost2 = _tgcount * _c_tave; end; return;
do_out: _nobns = _nobns + _n_per_q;
_q_out = _q_out + 1; _decile = 100 * _q_out / nquants; if ^_lastobs then _eprofit = _prev_ep; /* non-cummulative average profit, total profit, and average roi */ _eprofit = _prev_ep; _profit = _p_ave; Tprofit = _p_ave * _n_per_q; if _c_ave ^= 0 and _c_ave ^= . then do; _roi = _p_ave/_c_ave; _iscost0 = 'N'; end; else do; _roi = .; _iscost0 = 'Y'; end; /* cummulative average profit, total profit, and average roi */ if _roic ^= . and _roic ^= 0 then _costc = _profitc/_roic; else _costc = 0; _profitc = ((_profitc * (_nobns - _n_per_q)) + (_p_ave * _n_per_q)) /_nobns; Tprofitc = _profitc * _nobns; if (_costc + _c_ave * _n_per_q) ^= 0 then _roic = Tprofitc / (_costc * (_nobns - _n_per_q) + _c_ave * _n_per_q); else _roic = .; if _q_out > 1 then do; if abs(_profit - _profit9) < 0.00001 then _profit = _profit9 ; if abs(_profitc- _proftc9) < 0.00001 then _profitc = _proftc9 ;
if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) < 1E-7 then _roi = _roi9 ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) < 1E-7 then _roic = _roic9 ; end; end; if _q_out = 1 then do; _profitc = _profit; _roic = _roi; end; output;
if _q_out = 1 then do; _profit9 = _profit; _proftc9 = _profitc; _roi9 = _roi; _roic9 = _roic; end; else do; if abs(_profit - _profit9) > 0.00001 then _profit9 = _profit ; if abs(_profitc- _proftc9) > 0.00001 then _proftc9 = _profitc;
if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) > 1E-7 then _roi9 = _roi ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) > 1E-7 then _roic9 = _roic ; end; end; return; run;
data EMPROJ._A000002; merge EMPROJ._A000002 EMPROJ._000LFT2; run;
proc sort data=EMPROJ._000tran ; by descending _e_count; run;
data EMPROJ._A000006(keep=_tool_ _decile _cutoff _eprofit _cap _lift _resp _capc _liftc _respc _gcount version); set EMPROJ._000tran end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7;
retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _resp9 _respc9 _cap9 _capc9 _lift9 _liftc9; rename _e_prob = _cutoff; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Exact"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _e_count) < 1E-7 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_p = _e_count; _tgcount = _tgcount + 1; if _e_count > 0 then do; _tcount = _tcount + 1; end; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; end; else do; _ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do;
do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end; _count = _gcount * _ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; end; else do; _tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; link do_out; end;
_ave = _tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0; _tcount = _tgcount * _tave; end; return;
do_out: _nobns = _nobns + _n_per_q; _q_out = _q_out + 1; _decile = 100 * _q_out / nquants; _cap = _n_per_q * _ave * 100 / n_y_1; _lift = _ave / ( n_y_1 / sumfreq); _resp = _ave * 100;
_countc = _countc + _n_per_q * _ave; _capc = (_countc / n_y_1) * 100; _liftc = _capc / _decile; _respc = (_countc / _nobns) * 100; if ^_lastobs then _eprofit = _prev_ep; if _q_out > 1 then do; if abs(_resp - _resp9 ) < 1E-7 then _resp = _resp9 ; if abs(_respc - _respc9 ) < 1E-7 then _respc = _respc9 ; if abs(_cap - _cap9 ) < 1E-7 then _cap = _cap9 ; if abs(_capc - _capc9 ) < 1E-7 then _capc = _capc9 ; if abs(_lift - _lift9 ) < 1E-7 then _lift = _lift9 ; if abs(_liftc - _liftc9 ) < 1E-7 then _liftc = _liftc9 ; end; if _q_out = 1 then do; _respc = _resp; _capc = _cap; _liftc = _lift; end; _e_prob = .; if ^_lastobs then _e_prob = _prev_ep; output;
if _q_out = 1 then do; _resp9 = _resp; _respc9 = _respc; _cap9 = _cap; _capc9 = _capc; _lift9 = _lift; _liftc9 = _liftc; end; else do; if abs(_resp - _resp9 ) > 1E-7 then _resp9 = _resp ; if abs(_respc - _respc9 ) > 1E-7 then _respc9 = _respc ; if abs(_cap - _cap9 ) > 1E-7 then _cap9 = _cap ; if abs(_capc - _capc9 ) > 1E-7 then _capc9 = _capc ; if abs(_lift - _lift9 ) > 1E-7 then _lift9 = _lift ; if abs(_liftc - _liftc9 ) > 1E-7 then _liftc9 = _liftc ; end; return; run;
proc sort data=EMPROJ._000tran ; by descending _aprofit; run;
data EMPROJ._000LFT2(keep=_profit _roi _profitc _roic Tprofit Tprofitc proftype _iscost0); set EMPROJ._000tran end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7; retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _prev_ep 0; /* EP from previous observation. */ retain _prof2 0 _cost2 0 _tprof2 0 _tcost2 0; retain _profitc 0 _roic 0; retain _profit9 _proftc9 _roi9 _roic9; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Exact"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _aprofit) < 0.00001 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; _prof2 + _tprof2; _tprof2 = 0; _cost2 + _tcost2; _tcost2 = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_ep = _cur_ep; _prev_p = _aprofit; _tgcount = _tgcount + 1; if _aprofit > 0.5 then do; _tcount = _tcount + 1; end; _tprof2 + _aprofit; _tcost2 + _cost; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; _p_ave = _prof2/_gcount; _c_ave = _cost2/_gcount; end; else do; _ave = 0; _p_ave = 0; _c_ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do; do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end;
_count = _gcount * _ave; _prof2 = _gcount * _p_ave; _cost2 = _gcount * _c_ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; _p_tave = _tprof2/_tgcount; _c_tave = _tcost2/_tgcount; end; else do; _tave = 0; _p_tave = 0; _c_tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _p_ave = (_gcount * _p_ave + (_n_per_q - _gcount) * _p_tave) / _n_per_q; _c_ave = (_gcount * _c_ave + (_n_per_q - _gcount) * _c_tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; _prof2 = 0; _cost2 = 0; link do_out; end;
_ave = _tave; _p_ave = _p_tave; _c_ave = _c_tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0; _tcount = _tgcount * _tave; _tprof2 = _tgcount * _p_tave; _tcost2 = _tgcount * _c_tave; end; return;
do_out: _nobns = _nobns + _n_per_q;
_q_out = _q_out + 1; _decile = 100 * _q_out / nquants; if ^_lastobs then _eprofit = _prev_ep; /* non-cummulative average profit, total profit, and average roi */ _eprofit = _prev_ep; _profit = _p_ave; Tprofit = _p_ave * _n_per_q; if _c_ave ^= 0 and _c_ave ^= . then do; _roi = _p_ave/_c_ave; _iscost0 = 'N'; end; else do; _roi = .; _iscost0 = 'Y'; end; /* cummulative average profit, total profit, and average roi */ if _roic ^= . and _roic ^= 0 then _costc = _profitc/_roic; else _costc = 0; _profitc = ((_profitc * (_nobns - _n_per_q)) + (_p_ave * _n_per_q)) /_nobns; Tprofitc = _profitc * _nobns; if (_costc + _c_ave * _n_per_q) ^= 0 then _roic = Tprofitc / (_costc * (_nobns - _n_per_q) + _c_ave * _n_per_q); else _roic = .; if _q_out > 1 then do; if abs(_profit - _profit9) < 0.00001 then _profit = _profit9 ; if abs(_profitc- _proftc9) < 0.00001 then _profitc = _proftc9 ; if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) < 1E-7 then _roi = _roi9 ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) < 1E-7 then _roic = _roic9 ; end; end; if _q_out = 1 then do; _profitc = _profit; _roic = _roi; end; _e_prob = .; output;
if _q_out = 1 then do; _profit9 = _profit; _proftc9 = _profitc; _roi9 = _roi; _roic9 = _roic; end; else do; if abs(_profit - _profit9) > 0.00001 then _profit9 = _profit ; if abs(_profitc- _proftc9) > 0.00001 then _proftc9 = _profitc;
if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) > 1E-7 then _roi9 = _roi ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) > 1E-7 then _roic9 = _roic ; end; end; return; run; data EMPROJ._A000006; merge EMPROJ._A000006 EMPROJ._000LFT2; run;
* BASELINE의 %Response; data EMPROJ._A000005; set EMPROJ._A000002 end=_lastobs; length modelid $8; drop _resp _respc _profit _profitc _roi _roic x _decile; drop _lift _liftc cont_cap big_diff tprofit tprofitc; rename _resp2 = _resp; rename _respc2 = _respc; rename _profit2 = _profit; rename _proftc2 = _profitc; rename _roi2 = _roi; rename _roic2 = _roic; rename _lift2 = _lift; rename _liftc2 = _liftc; rename tprofit2 = tprofit; rename tproftc2 = tprofitc;
retain cont_cap; retain big_diff 0; modelid = 'Baseline'; _tool_ = 'Baseline'; modelnam = 'Baseline';
if _n_ = 1 then cont_cap = _cap; if abs(cont_cap - _cap) > 0.00001 then big_diff = 1; if _lastobs then do x = 1 to 10; _eprofit = .; _cutoff = .; _resp2 = _respc; _respc2 = _respc;
if big_diff then _cap = 100 / 10; else _cap = cont_cap;
_capc = (100 / 10) * x; _lift2 = _liftc; _liftc2 = _liftc; _profit2 = _profitc; _proftc2 = _profitc; tprofit2 = _profitc * _gcount; tproftc2 = (_profitc * _gcount) * x; _roi2 = _roic; _roic2 = _roic; output; end; run;
data EMPROJ._A000005; merge EMPROJ._A000002 EMPROJ._A000005; run;
data EMPROJ._000tmp1(keep= _TARGET _OUTPUT ); set EMPROJ._A00000H; length _aTarget _pTarget $16; rename _pTarget=_OUTPUT _aTarget=_TARGET; _aTarget = left(trim(put(RESPOND,BEST12.))); if P_RESPOND1 >= P_RESPOND0 then _pTarget = '1'; else _pTarget = '0'; run;
proc freq data=EMPROJ._000tmp1(rename=(_target=target _output=output)) noprint; table target * output / out=EMPROJ._A000009; table target /out=EMPROJ._000tmp3(keep=target count rename=(count=total)); quit;
data EMPROJ._A000009(drop =total); merge EMPROJ._A000009 EMPROJ._000tmp3; by target; label lvl_per = 'Percent'; lvl_per = (count/total) * 100; run;
data EMPROJ._A000009; set EMPROJ._A000009; target = upcase(target); run;
proc sort data=EMPROJ._A000009; by target output; run;
data EMPROJ._000tmp5(keep=target); set EMPROJ._A000009; run;
proc sort data=EMPROJ._000tmp5 NODUP; by target; run;
data EMPROJ._000tmp6; length target $%DMNORLEN output $%DMNORLEN count 8 percent 8 lvl_per 8; target = 'X'; output='X'; count=0;percent=0; lvl_per=0; stop; run; proc sort data=EMPROJ._000tmp6; by target output; run;
proc sort data=EMPROJ._A000009; by target output; run;
data EMPROJ._A000009; update EMPROJ._000tmp6 EMPROJ._A000009; by target output; run;
data EMPROJ._A00000D(keep=_tool _cutoff _avg _freq _lvlord rename=(_cutoff=cutoff _avg=avg _freq=freq _tool=tool _lvlord=lvlord)); set EMPROJ._A00000H end=last_obn; length _tool $15 _cutoff $2 _avg 8 _freq 8 _lvlord $1 _Ftarget $%DMNORLEN; drop _Ftarget; retain _afrq95 0 _afrq90 0 _afrq85 0 _afrq80 0 _afrq75 0 _afrq70 0 _afrq65 0 _afrq60 0 _afrq55 0 _afrq50 0 _afrq45 0 _afrq40 0 _afrq35 0 _afrq30 0 _afrq25 0 _afrq20 0 _afrq15 0 _afrq10 0 _afrq05 0 _acrt95 0 _acrt90 0 _acrt85 0 _acrt80 0 _acrt75 0 _acrt70 0 _acrt65 0 _acrt60 0 _acrt55 0 _acrt50 0 _acrt45 0 _acrt40 0 _acrt35 0 _acrt30 0 _acrt25 0 _acrt20 0 _acrt15 0 _acrt10 0 _acrt05 0 _bfrq95 0 _bfrq90 0 _bfrq85 0 _bfrq80 0 _bfrq75 0 _bfrq70 0 _bfrq65 0 _bfrq60 0 _bfrq55 0 _bfrq50 0 _bfrq45 0 _bfrq40 0 _bfrq35 0 _bfrq30 0 _bfrq25 0 _bfrq20 0 _bfrq15 0 _bfrq10 0 _bfrq05 0 _bcrt95 0 _bcrt90 0 _bcrt85 0 _bcrt80 0 _bcrt75 0 _bcrt70 0 _bcrt65 0 _bcrt60 0 _bcrt55 0 _bcrt50 0 _bcrt45 0 _bcrt40 0 _bcrt35 0 _bcrt30 0 _bcrt25 0 _bcrt20 0 _bcrt15 0 _bcrt10 0 _bcrt05 0;
_tool = "Tree"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if _Ftarget = '1' then _acrt = 1; else _acrt = 0;
if P_RESPOND1 >= .95 then link A95; if P_RESPOND1 >= .90 then link A90; if P_RESPOND1 >= .85 then link A85; if P_RESPOND1 >= .80 then link A80; if P_RESPOND1 >= .75 then link A75; if P_RESPOND1 >= .70 then link A70; if P_RESPOND1 >= .65 then link A65; if P_RESPOND1 >= .60 then link A60; if P_RESPOND1 >= .55 then link A55; if P_RESPOND1 >= .50 then link A50; if P_RESPOND1 >= .45 then link A45; if P_RESPOND1 >= .40 then link A40; if P_RESPOND1 >= .35 then link A35; if P_RESPOND1 >= .30 then link A30; if P_RESPOND1 >= .25 then link A25; if P_RESPOND1 >= .20 then link A20; if P_RESPOND1 >= .15 then link A15; if P_RESPOND1 >= .10 then link A10; if P_RESPOND1 >= .05 then link A05; /* process target level 2 */ if _Ftarget = '0' then _bcrt = 1; else _bcrt = 0;
if P_RESPOND0 >= .95 then link B95; if P_RESPOND0 >= .90 then link B90; if P_RESPOND0 >= .85 then link B85; if P_RESPOND0 >= .80 then link B80; if P_RESPOND0 >= .75 then link B75; if P_RESPOND0 >= .70 then link B70; if P_RESPOND0 >= .65 then link B65; if P_RESPOND0 >= .60 then link B60; if P_RESPOND0 >= .55 then link B55; if P_RESPOND0 >= .50 then link B50; if P_RESPOND0 >= .45 then link B45; if P_RESPOND0 >= .40 then link B40; if P_RESPOND0 >= .35 then link B35; if P_RESPOND0 >= .30 then link B30; if P_RESPOND0 >= .25 then link B25; if P_RESPOND0 >= .20 then link B20; if P_RESPOND0 >= .15 then link B15; if P_RESPOND0 >= .10 then link B10; if P_RESPOND0 >= .05 then link B05; if last_obn then do; if _afrq95 > 0 then _aavg95 = _acrt95 / _afrq95; if _afrq90 > 0 then _aavg90 = _acrt90 / _afrq90; if _afrq85 > 0 then _aavg85 = _acrt85 / _afrq85; if _afrq80 > 0 then _aavg80 = _acrt80 / _afrq80; if _afrq75 > 0 then _aavg75 = _acrt75 / _afrq75; if _afrq70 > 0 then _aavg70 = _acrt70 / _afrq70; if _afrq65 > 0 then _aavg65 = _acrt65 / _afrq65; if _afrq60 > 0 then _aavg60 = _acrt60 / _afrq60; if _afrq55 > 0 then _aavg55 = _acrt55 / _afrq55; if _afrq50 > 0 then _aavg50 = _acrt50 / _afrq50; if _afrq45 > 0 then _aavg45 = _acrt45 / _afrq45; if _afrq40 > 0 then _aavg40 = _acrt40 / _afrq40; if _afrq35 > 0 then _aavg35 = _acrt35 / _afrq35; if _afrq30 > 0 then _aavg30 = _acrt30 / _afrq30; if _afrq25 > 0 then _aavg25 = _acrt25 / _afrq25; if _afrq20 > 0 then _aavg20 = _acrt20 / _afrq20; if _afrq15 > 0 then _aavg15 = _acrt15 / _afrq15; if _afrq10 > 0 then _aavg10 = _acrt10 / _afrq10; if _afrq05 > 0 then _aavg05 = _acrt05 / _afrq05; if _bfrq95 > 0 then _bavg95 = _bcrt95 / _bfrq95; if _bfrq90 > 0 then _bavg90 = _bcrt90 / _bfrq90; if _bfrq85 > 0 then _bavg85 = _bcrt85 / _bfrq85; if _bfrq80 > 0 then _bavg80 = _bcrt80 / _bfrq80; if _bfrq75 > 0 then _bavg75 = _bcrt75 / _bfrq75; if _bfrq70 > 0 then _bavg70 = _bcrt70 / _bfrq70; if _bfrq65 > 0 then _bavg65 = _bcrt65 / _bfrq65; if _bfrq60 > 0 then _bavg60 = _bcrt60 / _bfrq60; if _bfrq55 > 0 then _bavg55 = _bcrt55 / _bfrq55; if _bfrq50 > 0 then _bavg50 = _bcrt50 / _bfrq50; if _bfrq45 > 0 then _bavg45 = _bcrt45 / _bfrq45; if _bfrq40 > 0 then _bavg40 = _bcrt40 / _bfrq40; if _bfrq35 > 0 then _bavg35 = _bcrt35 / _bfrq35; if _bfrq30 > 0 then _bavg30 = _bcrt30 / _bfrq30; if _bfrq25 > 0 then _bavg25 = _bcrt25 / _bfrq25; if _bfrq20 > 0 then _bavg20 = _bcrt20 / _bfrq20; if _bfrq15 > 0 then _bavg15 = _bcrt15 / _bfrq15; if _bfrq10 > 0 then _bavg10 = _bcrt10 / _bfrq10; if _bfrq05 > 0 then _bavg05 = _bcrt05 / _bfrq05; _cutoff='95';_avg=_aavg95;_freq=_afrq95;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='90';_avg=_aavg90;_freq=_afrq90;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='85';_avg=_aavg85;_freq=_afrq85;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='80';_avg=_aavg80;_freq=_afrq80;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='75';_avg=_aavg75;_freq=_afrq75;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='70';_avg=_aavg70;_freq=_afrq70;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='65';_avg=_aavg65;_freq=_afrq65;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='60';_avg=_aavg60;_freq=_afrq60;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='55';_avg=_aavg55;_freq=_afrq55;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='50';_avg=_aavg50;_freq=_afrq50;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='45';_avg=_aavg45;_freq=_afrq45;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='40';_avg=_aavg40;_freq=_afrq40;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='35';_avg=_aavg35;_freq=_afrq35;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='30';_avg=_aavg30;_freq=_afrq30;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='25';_avg=_aavg25;_freq=_afrq25;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='20';_avg=_aavg20;_freq=_afrq20;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='15';_avg=_aavg15;_freq=_afrq15;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='10';_avg=_aavg10;_freq=_afrq10;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='05';_avg=_aavg05;_freq=_afrq05;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='95';_avg=_bavg95;_freq=_bfrq95;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='90';_avg=_bavg90;_freq=_bfrq90;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='85';_avg=_bavg85;_freq=_bfrq85;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='80';_avg=_bavg80;_freq=_bfrq80;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='75';_avg=_bavg75;_freq=_bfrq75;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='70';_avg=_bavg70;_freq=_bfrq70;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='65';_avg=_bavg65;_freq=_bfrq65;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='60';_avg=_bavg60;_freq=_bfrq60;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='55';_avg=_bavg55;_freq=_bfrq55;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='50';_avg=_bavg50;_freq=_bfrq50;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='45';_avg=_bavg45;_freq=_bfrq45;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='40';_avg=_bavg40;_freq=_bfrq40;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='35';_avg=_bavg35;_freq=_bfrq35;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='30';_avg=_bavg30;_freq=_bfrq30;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='25';_avg=_bavg25;_freq=_bfrq25;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='20';_avg=_bavg20;_freq=_bfrq20;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='15';_avg=_bavg15;_freq=_bfrq15;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='10';_avg=_bavg10;_freq=_bfrq10;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='05';_avg=_bavg05;_freq=_bfrq05;_lvlord='B'; if _avg=. then _avg=0;output; end; return; A95: _afrq95 = _afrq95 + 1; if _acrt = 1 then _acrt95 = _acrt95 + 1; return; A90: _afrq90 = _afrq90 + 1; if _acrt = 1 then _acrt90 = _acrt90 + 1; return; A85: _afrq85 = _afrq85 + 1; if _acrt = 1 then _acrt85 = _acrt85 + 1; return; A80: _afrq80 = _afrq80 + 1; if _acrt = 1 then _acrt80 = _acrt80 + 1; return; A75: _afrq75 = _afrq75 + 1; if _acrt = 1 then _acrt75 = _acrt75 + 1; return; A70: _afrq70 = _afrq70 + 1; if _acrt = 1 then _acrt70 = _acrt70 + 1; return; A65: _afrq65 = _afrq65 + 1; if _acrt = 1 then _acrt65 = _acrt65 + 1; return; A60: _afrq60 = _afrq60 + 1; if _acrt = 1 then _acrt60 = _acrt60 + 1; return; A55: _afrq55 = _afrq55 + 1; if _acrt = 1 then _acrt55 = _acrt55 + 1; return; A50: _afrq50 = _afrq50 + 1; if _acrt = 1 then _acrt50 = _acrt50 + 1; return; A45: _afrq45 = _afrq45 + 1; if _acrt = 1 then _acrt45 = _acrt45 + 1; return; A40: _afrq40 = _afrq40 + 1; if _acrt = 1 then _acrt40 = _acrt40 + 1; return; A35: _afrq35 = _afrq35 + 1; if _acrt = 1 then _acrt35 = _acrt35 + 1; return; A30: _afrq30 = _afrq30 + 1; if _acrt = 1 then _acrt30 = _acrt30 + 1; return; A25: _afrq25 = _afrq25 + 1; if _acrt = 1 then _acrt25 = _acrt25 + 1; return; A20: _afrq20 = _afrq20 + 1; if _acrt = 1 then _acrt20 = _acrt20 + 1; return; A15: _afrq15 = _afrq15 + 1; if _acrt = 1 then _acrt15 = _acrt15 + 1; return; A10: _afrq10 = _afrq10 + 1; if _acrt = 1 then _acrt10 = _acrt10 + 1; return; A05: _afrq05 = _afrq05 + 1; if _acrt = 1 then _acrt05 = _acrt05 + 1; return; B95: _bfrq95 = _bfrq95 + 1; if _bcrt = 1 then _bcrt95 = _bcrt95 + 1; return; B90: _bfrq90 = _bfrq90 + 1; if _bcrt = 1 then _bcrt90 = _bcrt90 + 1; return; B85: _bfrq85 = _bfrq85 + 1; if _bcrt = 1 then _bcrt85 = _bcrt85 + 1; return; B80: _bfrq80 = _bfrq80 + 1; if _bcrt = 1 then _bcrt80 = _bcrt80 + 1; return; B75: _bfrq75 = _bfrq75 + 1; if _bcrt = 1 then _bcrt75 = _bcrt75 + 1; return; B70: _bfrq70 = _bfrq70 + 1; if _bcrt = 1 then _bcrt70 = _bcrt70 + 1; return; B65: _bfrq65 = _bfrq65 + 1; if _bcrt = 1 then _bcrt65 = _bcrt65 + 1; return; B60: _bfrq60 = _bfrq60 + 1; if _bcrt = 1 then _bcrt60 = _bcrt60 + 1; return; B55: _bfrq55 = _bfrq55 + 1; if _bcrt = 1 then _bcrt55 = _bcrt55 + 1; return; B50: _bfrq50 = _bfrq50 + 1; if _bcrt = 1 then _bcrt50 = _bcrt50 + 1; return; B45: _bfrq45 = _bfrq45 + 1; if _bcrt = 1 then _bcrt45 = _bcrt45 + 1; return; B40: _bfrq40 = _bfrq40 + 1; if _bcrt = 1 then _bcrt40 = _bcrt40 + 1; return; B35: _bfrq35 = _bfrq35 + 1; if _bcrt = 1 then _bcrt35 = _bcrt35 + 1; return; B30: _bfrq30 = _bfrq30 + 1; if _bcrt = 1 then _bcrt30 = _bcrt30 + 1; return; B25: _bfrq25 = _bfrq25 + 1; if _bcrt = 1 then _bcrt25 = _bcrt25 + 1; return; B20: _bfrq20 = _bfrq20 + 1; if _bcrt = 1 then _bcrt20 = _bcrt20 + 1; return; B15: _bfrq15 = _bfrq15 + 1; if _bcrt = 1 then _bcrt15 = _bcrt15 + 1; return; B10: _bfrq10 = _bfrq10 + 1; if _bcrt = 1 then _bcrt10 = _bcrt10 + 1; return; B05: _bfrq05 = _bfrq05 + 1; if _bcrt = 1 then _bcrt05 = _bcrt05 + 1; return; run;
data EMPROJ._000sroc(keep=_tool _se _sp _lvlord rename=(_se=se _sp=sp _tool=tool _lvlord=lvlord)); set EMPROJ._A00000H end=last_obn; length _tool $15 _lvlord $1 _Ftarget $%DMNORLEN; drop _Ftarget; retain _aa99 _ab99 _ac99 _ad99 _aa95 _ab95 _ac95 _ad95 _aa90 _ab90 _ac90 _ad90 _aa85 _ab85 _ac85 _ad85 _aa80 _ab80 _ac80 _ad80 _aa75 _ab75 _ac75 _ad75 _aa70 _ab70 _ac70 _ad70 _aa65 _ab65 _ac65 _ad65 _aa60 _ab60 _ac60 _ad60 _aa55 _ab55 _ac55 _ad55 _aa50 _ab50 _ac50 _ad50 _aa45 _ab45 _ac45 _ad45 _aa40 _ab40 _ac40 _ad40 _aa35 _ab35 _ac35 _ad35 _aa30 _ab30 _ac30 _ad30 _aa25 _ab25 _ac25 _ad25 _aa20 _ab20 _ac20 _ad20 _aa15 _ab15 _ac15 _ad15 _aa10 _ab10 _ac10 _ad10 _aa05 _ab05 _ac05 _ad05 _aa00 _ab00 _ac00 _ad00 _ba99 _bb99 _bc99 _bd99 _ba95 _bb95 _bc95 _bd95 _ba90 _bb90 _bc90 _bd90 _ba85 _bb85 _bc85 _bd85 _ba80 _bb80 _bc80 _bd80 _ba75 _bb75 _bc75 _bd75 _ba70 _bb70 _bc70 _bd70 _ba65 _bb65 _bc65 _bd65 _ba60 _bb60 _bc60 _bd60 _ba55 _bb55 _bc55 _bd55 _ba50 _bb50 _bc50 _bd50 _ba45 _bb45 _bc45 _bd45 _ba40 _bb40 _bc40 _bd40 _ba35 _bb35 _bc35 _bd35 _ba30 _bb30 _bc30 _bd30 _ba25 _bb25 _bc25 _bd25 _ba20 _bb20 _bc20 _bd20 _ba15 _bb15 _bc15 _bd15 _ba10 _bb10 _bc10 _bd10 _ba05 _bb05 _bc05 _bd05 _ba00 _bb00 _bc00 _bd00 0;
_tool = "Tree"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if P_RESPOND1 = 1 then do; if _Ftarget = '1' then _aa99 = _aa99 + 1; else _ab99 = _ab99 + 1; end; else do; if _Ftarget = '1' then _ac99 = _ac99 + 1; else _ad99 = _ad99 + 1; end;
if P_RESPOND1 >= .95 then do; if _Ftarget = '1' then _aa95 = _aa95 + 1; else _ab95 = _ab95 + 1; end; else do; if _Ftarget = '1' then _ac95 = _ac95 + 1; else _ad95 = _ad95 + 1; end;
if P_RESPOND1 >= .90 then do; if _Ftarget = '1' then _aa90 = _aa90 + 1; else _ab90 = _ab90 + 1; end; else do; if _Ftarget = '1' then _ac90 = _ac90 + 1; else _ad90 = _ad90 + 1; end;
if P_RESPOND1 >= .85 then do; if _Ftarget = '1' then _aa85 = _aa85 + 1; else _ab85 = _ab85 + 1; end; else do; if _Ftarget = '1' then _ac85 = _ac85 + 1; else _ad85 = _ad85 + 1; end;
if P_RESPOND1 >= .80 then do; if _Ftarget = '1' then _aa80 = _aa80 + 1; else _ab80 = _ab80 + 1; end; else do; if _Ftarget = '1' then _ac80 = _ac80 + 1; else _ad80 = _ad80 + 1; end;
if P_RESPOND1 >= .75 then do; if _Ftarget = '1' then _aa75 = _aa75 + 1; else _ab75 = _ab75 + 1; end; else do; if _Ftarget = '1' then _ac75 = _ac75 + 1; else _ad75 = _ad75 + 1; end;
if P_RESPOND1 >= .70 then do; if _Ftarget = '1' then _aa70 = _aa70 + 1; else _ab70 = _ab70 + 1; end; else do; if _Ftarget = '1' then _ac70 = _ac70 + 1; else _ad70 = _ad70 + 1; end;
if P_RESPOND1 >= .65 then do; if _Ftarget = '1' then _aa65 = _aa65 + 1; else _ab65 = _ab65 + 1; end; else do; if _Ftarget = '1' then _ac65 = _ac65 + 1; else _ad65 = _ad65 + 1; end;
if P_RESPOND1 >= .60 then do; if _Ftarget = '1' then _aa60 = _aa60 + 1; else _ab60 = _ab60 + 1; end; else do; if _Ftarget = '1' then _ac60 = _ac60 + 1; else _ad60 = _ad60 + 1; end;
if P_RESPOND1 >= .55 then do; if _Ftarget = '1' then _aa55 = _aa55 + 1; else _ab55 = _ab55 + 1; end; else do; if _Ftarget = '1' then _ac55 = _ac55 + 1; else _ad55 = _ad55 + 1; end;
if P_RESPOND1 >= .50 then do; if _Ftarget = '1' then _aa50 = _aa50 + 1; else _ab50 = _ab50 + 1; end; else do; if _Ftarget = '1' then _ac50 = _ac50 + 1; else _ad50 = _ad50 + 1; end;
if P_RESPOND1 >= .45 then do; if _Ftarget = '1' then _aa45 = _aa45 + 1; else _ab45 = _ab45 + 1; end; else do; if _Ftarget = '1' then _ac45 = _ac45 + 1; else _ad45 = _ad45 + 1; end;
if P_RESPOND1 >= .40 then do; if _Ftarget = '1' then _aa40 = _aa40 + 1; else _ab40 = _ab40 + 1; end; else do; if _Ftarget = '1' then _ac40 = _ac40 + 1; else _ad40 = _ad40 + 1; end;
if P_RESPOND1 >= .35 then do; if _Ftarget = '1' then _aa35 = _aa35 + 1; else _ab35 = _ab35 + 1; end; else do; if _Ftarget = '1' then _ac35 = _ac35 + 1; else _ad35 = _ad35 + 1; end;
if P_RESPOND1 >= .30 then do; if _Ftarget = '1' then _aa30 = _aa30 + 1; else _ab30 = _ab30 + 1; end; else do; if _Ftarget = '1' then _ac30 = _ac30 + 1; else _ad30 = _ad30 + 1; end;
if P_RESPOND1 >= .25 then do; if _Ftarget = '1' then _aa25 = _aa25 + 1; else _ab25 = _ab25 + 1; end; else do; if _Ftarget = '1' then _ac25 = _ac25 + 1; else _ad25 = _ad25 + 1; end;
if P_RESPOND1 >= .20 then do; if _Ftarget = '1' then _aa20 = _aa20 + 1; else _ab20 = _ab20 + 1; end; else do; if _Ftarget = '1' then _ac20 = _ac20 + 1; else _ad20 = _ad20 + 1; end;
if P_RESPOND1 >= .15 then do; if _Ftarget = '1' then _aa15 = _aa15 + 1; else _ab15 = _ab15 + 1; end; else do; if _Ftarget = '1' then _ac15 = _ac15 + 1; else _ad15 = _ad15 + 1; end;
if P_RESPOND1 >= .10 then do; if _Ftarget = '1' then _aa10 = _aa10 + 1; else _ab10 = _ab10 + 1; end; else do; if _Ftarget = '1' then _ac10 = _ac10 + 1; else _ad10 = _ad10 + 1; end;
if P_RESPOND1 >= .05 then do; if _Ftarget = '1' then _aa05 = _aa05 + 1; else _ab05 = _ab05 + 1; end; else do; if _Ftarget = '1' then _ac05 = _ac05 + 1; else _ad05 = _ad05 + 1; end;
if P_RESPOND1 >= 0 then do; if _Ftarget = '1' then _aa00 = _aa00 + 1; else _ab00 = _ab00 + 1; end; /* process target level 2 */ if P_RESPOND0 = 1 then do; if _Ftarget = '0' then _ba99 = _ba99 + 1; else _bb99 = _bb99 + 1; end; else do; if _Ftarget = '0' then _bc99 = _bc99 + 1; else _bd99 = _bd99 + 1; end;
if P_RESPOND0 >= .95 then do; if _Ftarget = '0' then _ba95 = _ba95 + 1; else _bb95 = _bb95 + 1; end; else do; if _Ftarget = '0' then _bc95 = _bc95 + 1; else _bd95 = _bd95 + 1; end;
if P_RESPOND0 >= .90 then do; if _Ftarget = '0' then _ba90 = _ba90 + 1; else _bb90 = _bb90 + 1; end; else do; if _Ftarget = '0' then _bc90 = _bc90 + 1; else _bd90 = _bd90 + 1; end;
if P_RESPOND0 >= .85 then do; if _Ftarget = '0' then _ba85 = _ba85 + 1; else _bb85 = _bb85 + 1; end; else do; if _Ftarget = '0' then _bc85 = _bc85 + 1; else _bd85 = _bd85 + 1; end;
if P_RESPOND0 >= .80 then do; if _Ftarget = '0' then _ba80 = _ba80 + 1; else _bb80 = _bb80 + 1; end; else do; if _Ftarget = '0' then _bc80 = _bc80 + 1; else _bd80 = _bd80 + 1; end;
if P_RESPOND0 >= .75 then do; if _Ftarget = '0' then _ba75 = _ba75 + 1; else _bb75 = _bb75 + 1; end; else do; if _Ftarget = '0' then _bc75 = _bc75 + 1; else _bd75 = _bd75 + 1; end;
if P_RESPOND0 >= .70 then do; if _Ftarget = '0' then _ba70 = _ba70 + 1; else _bb70 = _bb70 + 1; end; else do; if _Ftarget = '0' then _bc70 = _bc70 + 1; else _bd70 = _bd70 + 1; end;
if P_RESPOND0 >= .65 then do; if _Ftarget = '0' then _ba65 = _ba65 + 1; else _bb65 = _bb65 + 1; end; else do; if _Ftarget = '0' then _bc65 = _bc65 + 1; else _bd65 = _bd65 + 1; end;
if P_RESPOND0 >= .60 then do; if _Ftarget = '0' then _ba60 = _ba60 + 1; else _bb60 = _bb60 + 1; end; else do; if _Ftarget = '0' then _bc60 = _bc60 + 1; else _bd60 = _bd60 + 1; end;
if P_RESPOND0 >= .55 then do; if _Ftarget = '0' then _ba55 = _ba55 + 1; else _bb55 = _bb55 + 1; end; else do; if _Ftarget = '0' then _bc55 = _bc55 + 1; else _bd55 = _bd55 + 1; end;
if P_RESPOND0 >= .50 then do; if _Ftarget = '0' then _ba50 = _ba50 + 1; else _bb50 = _bb50 + 1; end; else do; if _Ftarget = '0' then _bc50 = _bc50 + 1; else _bd50 = _bd50 + 1; end;
if P_RESPOND0 >= .45 then do; if _Ftarget = '0' then _ba45 = _ba45 + 1; else _bb45 = _bb45 + 1; end; else do; if _Ftarget = '0' then _bc45 = _bc45 + 1; else _bd45 = _bd45 + 1; end;
if P_RESPOND0 >= .40 then do; if _Ftarget = '0' then _ba40 = _ba40 + 1; else _bb40 = _bb40 + 1; end; else do; if _Ftarget = '0' then _bc40 = _bc40 + 1; else _bd40 = _bd40 + 1; end;
if P_RESPOND0 >= .35 then do; if _Ftarget = '0' then _ba35 = _ba35 + 1; else _bb35 = _bb35 + 1; end; else do; if _Ftarget = '0' then _bc35 = _bc35 + 1; else _bd35 = _bd35 + 1; end;
if P_RESPOND0 >= .30 then do; if _Ftarget = '0' then _ba30 = _ba30 + 1; else _bb30 = _bb30 + 1; end; else do; if _Ftarget = '0' then _bc30 = _bc30 + 1; else _bd30 = _bd30 + 1; end;
if P_RESPOND0 >= .25 then do; if _Ftarget = '0' then _ba25 = _ba25 + 1; else _bb25 = _bb25 + 1; end; else do; if _Ftarget = '0' then _bc25 = _bc25 + 1; else _bd25 = _bd25 + 1; end;
if P_RESPOND0 >= .20 then do; if _Ftarget = '0' then _ba20 = _ba20 + 1; else _bb20 = _bb20 + 1; end; else do; if _Ftarget = '0' then _bc20 = _bc20 + 1; else _bd20 = _bd20 + 1; end;
if P_RESPOND0 >= .15 then do; if _Ftarget = '0' then _ba15 = _ba15 + 1; else _bb15 = _bb15 + 1; end; else do; if _Ftarget = '0' then _bc15 = _bc15 + 1; else _bd15 = _bd15 + 1; end;
if P_RESPOND0 >= .10 then do; if _Ftarget = '0' then _ba10 = _ba10 + 1; else _bb10 = _bb10 + 1; end; else do; if _Ftarget = '0' then _bc10 = _bc10 + 1; else _bd10 = _bd10 + 1; end;
if P_RESPOND0 >= .05 then do; if _Ftarget = '0' then _ba05 = _ba05 + 1; else _bb05 = _bb05 + 1; end; else do; if _Ftarget = '0' then _bc05 = _bc05 + 1; else _bd05 = _bd05 + 1; end;
if P_RESPOND0 >= 0 then do; if _Ftarget = '0' then _ba00 = _ba00 + 1; else _bb00 = _bb00 + 1; end; /* else do; * will never get hee * if _Ftarget = '0' then _bc00 = _bc00 + 1; else _bd00 = _bd00 + 1; end; */ if last_obn then do; if (_aa99+_ac99)> 0 then _se = _aa99/(_aa99+_ac99); else _se = 0; if (_ab99+_ad99)> 0 then _sp = 1-(_ad99/(_ab99+_ad99)); else _sp = 0; _lvlord = 'A'; output;
if (_aa95+_ac95)> 0 then _se = _aa95/(_aa95+_ac95); else _se = 0; if (_ab95+_ad95)> 0 then _sp = 1-(_ad95/(_ab95+_ad95)); else _sp = 0; _lvlord = 'A'; output;
if (_aa90+_ac90)> 0 then _se = _aa90/(_aa90+_ac90); else _se = 0; if (_ab90+_ad90)> 0 then _sp = 1-(_ad90/(_ab90+_ad90)); else _sp = 0; _lvlord = 'A'; output;
if (_aa85+_ac85)> 0 then _se = _aa85/(_aa85+_ac85); else _se = 0; if (_ab85+_ad85)> 0 then _sp = 1-(_ad85/(_ab85+_ad85)); else _sp = 0; _lvlord = 'A'; output;
if (_aa80+_ac80)> 0 then _se = _aa80/(_aa80+_ac80); else _se = 0; if (_ab80+_ad80)> 0 then _sp = 1-(_ad80/(_ab80+_ad80)); else _sp = 0; _lvlord = 'A'; output;
if (_aa75+_ac75)> 0 then _se = _aa75/(_aa75+_ac75); else _se = 0; if (_ab75+_ad75)> 0 then _sp = 1-(_ad75/(_ab75+_ad75)); else _sp = 0; _lvlord = 'A'; output;
if (_aa70+_ac70)> 0 then _se = _aa70/(_aa70+_ac70); else _se = 0; if (_ab70+_ad70)> 0 then _sp = 1-(_ad70/(_ab70+_ad70)); else _sp = 0; _lvlord = 'A'; output;
if (_aa65+_ac65)> 0 then _se = _aa65/(_aa65+_ac65); else _se = 0; if (_ab65+_ad65)> 0 then _sp = 1-(_ad65/(_ab65+_ad65)); else _sp = 0; _lvlord = 'A'; output;
if (_aa60+_ac60)> 0 then _se = _aa60/(_aa60+_ac60); else _se = 0; if (_ab60+_ad60)> 0 then _sp = 1-(_ad60/(_ab60+_ad60)); else _sp = 0; _lvlord = 'A'; output;
if (_aa55+_ac55)> 0 then _se = _aa55/(_aa55+_ac55); else _se = 0; if (_ab55+_ad55)> 0 then _sp = 1-(_ad55/(_ab55+_ad55)); else _sp = 0; _lvlord = 'A'; output;
if (_aa50+_ac50)> 0 then _se = _aa50/(_aa50+_ac50); else _se = 0; if (_ab50+_ad50)> 0 then _sp = 1-(_ad50/(_ab50+_ad50)); else _sp = 0; _lvlord = 'A'; output;
if (_aa45+_ac45)> 0 then _se = _aa45/(_aa45+_ac45); else _se = 0; if (_ab45+_ad45)> 0 then _sp = 1-(_ad45/(_ab45+_ad45)); else _sp = 0; _lvlord = 'A'; output;
if (_aa40+_ac40)> 0 then _se = _aa40/(_aa40+_ac40); else _se = 0; if (_ab40+_ad40)> 0 then _sp = 1-(_ad40/(_ab40+_ad40)); else _sp = 0; _lvlord = 'A'; output;
if (_aa35+_ac35)> 0 then _se = _aa35/(_aa35+_ac35); else _se = 0; if (_ab35+_ad35)> 0 then _sp = 1-(_ad35/(_ab35+_ad35)); else _sp = 0; _lvlord = 'A'; output;
if (_aa30+_ac30)> 0 then _se = _aa30/(_aa30+_ac30); else _se = 0; if (_ab30+_ad30)> 0 then _sp = 1-(_ad30/(_ab30+_ad30)); else _sp = 0; _lvlord = 'A'; output;
if (_aa25+_ac25)> 0 then _se = _aa25/(_aa25+_ac25); else _se = 0; if (_ab25+_ad25)> 0 then _sp = 1-(_ad25/(_ab25+_ad25)); else _sp = 0; _lvlord = 'A'; output;
if (_aa20+_ac20)> 0 then _se = _aa20/(_aa20+_ac20); else _se = 0; if (_ab20+_ad20)> 0 then _sp = 1-(_ad20/(_ab20+_ad20)); else _sp = 0; _lvlord = 'A'; output;
if (_aa15+_ac15)> 0 then _se = _aa15/(_aa15+_ac15); else _se = 0; if (_ab15+_ad15)> 0 then _sp = 1-(_ad15/(_ab15+_ad15)); else _sp = 0; _lvlord = 'A'; output;
if (_aa10+_ac10)> 0 then _se = _aa10/(_aa10+_ac10); else _se = 0; if (_ab10+_ad10)> 0 then _sp = 1-(_ad10/(_ab10+_ad10)); else _sp = 0; _lvlord = 'A'; output;
if (_aa05+_ac05)> 0 then _se = _aa05/(_aa05+_ac05); else _se = 0; if (_ab05+_ad05)> 0 then _sp = 1-(_ad05/(_ab05+_ad05)); else _sp = 0; _lvlord = 'A'; output;
_se=1; _sp=1; _lvlord = 'A'; output; if (_ba99+_bc99)> 0 then _se = _ba99/(_ba99+_bc99); else _se = 0; if (_bb99+_bd99)> 0 then _sp = 1-(_bd99/(_bb99+_bd99)); else _sp = 0; _lvlord = 'B'; output;
if (_ba95+_bc95)> 0 then _se = _ba95/(_ba95+_bc95); else _se = 0; if (_bb95+_bd95)> 0 then _sp = 1-(_bd95/(_bb95+_bd95)); else _sp = 0; _lvlord = 'B'; output;
if (_ba90+_bc90)> 0 then _se = _ba90/(_ba90+_bc90); else _se = 0; if (_bb90+_bd90)> 0 then _sp = 1-(_bd90/(_bb90+_bd90)); else _sp = 0; _lvlord = 'B'; output;
if (_ba85+_bc85)> 0 then _se = _ba85/(_ba85+_bc85); else _se = 0; if (_bb85+_bd85)> 0 then _sp = 1-(_bd85/(_bb85+_bd85)); else _sp = 0; _lvlord = 'B'; output;
if (_ba80+_bc80)> 0 then _se = _ba80/(_ba80+_bc80); else _se = 0; if (_bb80+_bd80)> 0 then _sp = 1-(_bd80/(_bb80+_bd80)); else _sp = 0; _lvlord = 'B'; output;
if (_ba75+_bc75)> 0 then _se = _ba75/(_ba75+_bc75); else _se = 0; if (_bb75+_bd75)> 0 then _sp = 1-(_bd75/(_bb75+_bd75)); else _sp = 0; _lvlord = 'B'; output;
if (_ba70+_bc70)> 0 then _se = _ba70/(_ba70+_bc70); else _se = 0; if (_bb70+_bd70)> 0 then _sp = 1-(_bd70/(_bb70+_bd70)); else _sp = 0; _lvlord = 'B'; output;
if (_ba65+_bc65)> 0 then _se = _ba65/(_ba65+_bc65); else _se = 0; if (_bb65+_bd65)> 0 then _sp = 1-(_bd65/(_bb65+_bd65)); else _sp = 0; _lvlord = 'B'; output;
if (_ba60+_bc60)> 0 then _se = _ba60/(_ba60+_bc60); else _se = 0; if (_bb60+_bd60)> 0 then _sp = 1-(_bd60/(_bb60+_bd60)); else _sp = 0; _lvlord = 'B'; output;
if (_ba55+_bc55)> 0 then _se = _ba55/(_ba55+_bc55); else _se = 0; if (_bb55+_bd55)> 0 then _sp = 1-(_bd55/(_bb55+_bd55)); else _sp = 0; _lvlord = 'B'; output;
if (_ba50+_bc50)> 0 then _se = _ba50/(_ba50+_bc50); else _se = 0; if (_bb50+_bd50)> 0 then _sp = 1-(_bd50/(_bb50+_bd50)); else _sp = 0; _lvlord = 'B'; output;
if (_ba45+_bc45)> 0 then _se = _ba45/(_ba45+_bc45); else _se = 0; if (_bb45+_bd45)> 0 then _sp = 1-(_bd45/(_bb45+_bd45)); else _sp = 0; _lvlord = 'B'; output;
if (_ba40+_bc40)> 0 then _se = _ba40/(_ba40+_bc40); else _se = 0; if (_bb40+_bd40)> 0 then _sp = 1-(_bd40/(_bb40+_bd40)); else _sp = 0; _lvlord = 'B'; output;
if (_ba35+_bc35)> 0 then _se = _ba35/(_ba35+_bc35); else _se = 0; if (_bb35+_bd35)> 0 then _sp = 1-(_bd35/(_bb35+_bd35)); else _sp = 0; _lvlord = 'B'; output;
if (_ba30+_bc30)> 0 then _se = _ba30/(_ba30+_bc30); else _se = 0; if (_bb30+_bd30)> 0 then _sp = 1-(_bd30/(_bb30+_bd30)); else _sp = 0; _lvlord = 'B'; output;
if (_ba25+_bc25)> 0 then _se = _ba25/(_ba25+_bc25); else _se = 0; if (_bb25+_bd25)> 0 then _sp = 1-(_bd25/(_bb25+_bd25)); else _sp = 0; _lvlord = 'B'; output;
if (_ba20+_bc20)> 0 then _se = _ba20/(_ba20+_bc20); else _se = 0; if (_bb20+_bd20)> 0 then _sp = 1-(_bd20/(_bb20+_bd20)); else _sp = 0; _lvlord = 'B'; output;
if (_ba15+_bc15)> 0 then _se = _ba15/(_ba15+_bc15); else _se = 0; if (_bb15+_bd15)> 0 then _sp = 1-(_bd15/(_bb15+_bd15)); else _sp = 0; _lvlord = 'B'; output;
if (_ba10+_bc10)> 0 then _se = _ba10/(_ba10+_bc10); else _se = 0; if (_bb10+_bd10)> 0 then _sp = 1-(_bd10/(_bb10+_bd10)); else _sp = 0; _lvlord = 'B'; output;
if (_ba05+_bc05)> 0 then _se = _ba05/(_ba05+_bc05); else _se = 0; if (_bb05+_bd05)> 0 then _sp = 1-(_bd05/(_bb05+_bd05)); else _sp = 0; _lvlord = 'B'; output;
_se=1; _sp=1; _lvlord = 'B'; output; /* replaced by the line above if (_ba00+_bc00)> 0 then _se = _ba00/(_ba00+_bc00); else _se = 0; if (_bb00+_bd00)> 0 then _sp = 1-(_bd00/(_bb00+_bd00)); else _sp = 0; _lvlord = 'B'; output; */ end; run;
proc sql; create view EMPROJ._000srv as select * from EMPROJ._000sroc where lvlord = "A"; quit; /* proc datasets lib= EMPROJ nolist; delete _000srv /mt=view; quit; */ proc sql; create view EMPROJ._000srv as select * from EMPROJ._000sroc where lvlord = "B"; quit; /* proc datasets lib= EMPROJ nolist; delete _000srv /mt=view; quit; */
data EMPROJ._A00000E; set EMPROJ._000sroc; if _n_ = 1 then do; sp = 0; se = 1; lvlord = 'A'; output; sp = 0.1; se = 1; lvlord = 'A'; output; sp = 0.2; se = 1; lvlord = 'A'; output; sp = 0.3; se = 1; lvlord = 'A'; output; sp = 0.4; se = 1; lvlord = 'A'; output; sp = 0.5; se = 1; lvlord = 'A'; output; sp = 0.6; se = 1; lvlord = 'A'; output; sp = 0.7; se = 1; lvlord = 'A'; output; sp = 0.8; se = 1; lvlord = 'A'; output; sp = 0.9; se = 1; lvlord = 'A'; output; sp = 1; se = 1; lvlord = 'A'; output; sp = 0; se = 1; lvlord = 'B'; output; sp = 0.1; se = 1; lvlord = 'B'; output; sp = 0.2; se = 1; lvlord = 'B'; output; sp = 0.3; se = 1; lvlord = 'B'; output; sp = 0.4; se = 1; lvlord = 'B'; output; sp = 0.5; se = 1; lvlord = 'B'; output; sp = 0.6; se = 1; lvlord = 'B'; output; sp = 0.7; se = 1; lvlord = 'B'; output; sp = 0.8; se = 1; lvlord = 'B'; output; sp = 0.9; se = 1; lvlord = 'B'; output; sp = 1; se = 1; lvlord = 'B'; output; stop; end; run;
data EMPROJ._A00000F(keep=_tool _thresh _freq _lvlord _predict _actual rename=(_thresh=thresh _predict=predict _actual=actual _freq=freq _tool=tool _lvlord=lvlord)); set EMPROJ._A00000H end=last_obn; length _tool $15 _lvlord $1 _predict _actual $%DMNORLEN _freq _thresh 8 _Ftarget $%DMNORLEN; drop _Ftarget; retain _aa99 _ab99 _ac99 _ad99 _aa95 _ab95 _ac95 _ad95 _aa90 _ab90 _ac90 _ad90 _aa85 _ab85 _ac85 _ad85 _aa80 _ab80 _ac80 _ad80 _aa75 _ab75 _ac75 _ad75 _aa70 _ab70 _ac70 _ad70 _aa65 _ab65 _ac65 _ad65 _aa60 _ab60 _ac60 _ad60 _aa55 _ab55 _ac55 _ad55 _aa50 _ab50 _ac50 _ad50 _aa45 _ab45 _ac45 _ad45 _aa40 _ab40 _ac40 _ad40 _aa35 _ab35 _ac35 _ad35 _aa30 _ab30 _ac30 _ad30 _aa25 _ab25 _ac25 _ad25 _aa20 _ab20 _ac20 _ad20 _aa15 _ab15 _ac15 _ad15 _aa10 _ab10 _ac10 _ad10 _aa05 _ab05 _ac05 _ad05 _aa00 _ab00 _ac00 _ad00 _ba99 _bb99 _bc99 _bd99 _ba95 _bb95 _bc95 _bd95 _ba90 _bb90 _bc90 _bd90 _ba85 _bb85 _bc85 _bd85 _ba80 _bb80 _bc80 _bd80 _ba75 _bb75 _bc75 _bd75 _ba70 _bb70 _bc70 _bd70 _ba65 _bb65 _bc65 _bd65 _ba60 _bb60 _bc60 _bd60 _ba55 _bb55 _bc55 _bd55 _ba50 _bb50 _bc50 _bd50 _ba45 _bb45 _bc45 _bd45 _ba40 _bb40 _bc40 _bd40 _ba35 _bb35 _bc35 _bd35 _ba30 _bb30 _bc30 _bd30 _ba25 _bb25 _bc25 _bd25 _ba20 _bb20 _bc20 _bd20 _ba15 _bb15 _bc15 _bd15 _ba10 _bb10 _bc10 _bd10 _ba05 _bb05 _bc05 _bd05 _ba00 _bb00 _bc00 _bd00 0 ;
_tool = "SPLTTOOL"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if P_RESPOND1 = 1 then do; if _Ftarget = '1' then _aa99 = _aa99 + 1; else _ab99 = _ab99 + 1; end; else do; if _Ftarget = '1' then _ac99 = _ac99 + 1; else _ad99 = _ad99 + 1; end;
if P_RESPOND1 >= .95 then do; if _Ftarget = '1' then _aa95 = _aa95 + 1; else _ab95 = _ab95 + 1; end; else do; if _Ftarget = '1' then _ac95 = _ac95 + 1; else _ad95 = _ad95 + 1; end;
if P_RESPOND1 >= .90 then do; if _Ftarget = '1' then _aa90 = _aa90 + 1; else _ab90 = _ab90 + 1; end; else do; if _Ftarget = '1' then _ac90 = _ac90 + 1; else _ad90 = _ad90 + 1; end;
if P_RESPOND1 >= .85 then do; if _Ftarget = '1' then _aa85 = _aa85 + 1; else _ab85 = _ab85 + 1; end; else do; if _Ftarget = '1' then _ac85 = _ac85 + 1; else _ad85 = _ad85 + 1; end;
if P_RESPOND1 >= .80 then do; if _Ftarget = '1' then _aa80 = _aa80 + 1; else _ab80 = _ab80 + 1; end; else do; if _Ftarget = '1' then _ac80 = _ac80 + 1; else _ad80 = _ad80 + 1; end;
if P_RESPOND1 >= .75 then do; if _Ftarget = '1' then _aa75 = _aa75 + 1; else _ab75 = _ab75 + 1; end; else do; if _Ftarget = '1' then _ac75 = _ac75 + 1; else _ad75 = _ad75 + 1; end;
if P_RESPOND1 >= .70 then do; if _Ftarget = '1' then _aa70 = _aa70 + 1; else _ab70 = _ab70 + 1; end; else do; if _Ftarget = '1' then _ac70 = _ac70 + 1; else _ad70 = _ad70 + 1; end;
if P_RESPOND1 >= .65 then do; if _Ftarget = '1' then _aa65 = _aa65 + 1; else _ab65 = _ab65 + 1; end; else do; if _Ftarget = '1' then _ac65 = _ac65 + 1; else _ad65 = _ad65 + 1; end;
if P_RESPOND1 >= .60 then do; if _Ftarget = '1' then _aa60 = _aa60 + 1; else _ab60 = _ab60 + 1; end; else do; if _Ftarget = '1' then _ac60 = _ac60 + 1; else _ad60 = _ad60 + 1; end;
if P_RESPOND1 >= .55 then do; if _Ftarget = '1' then _aa55 = _aa55 + 1; else _ab55 = _ab55 + 1; end; else do; if _Ftarget = '1' then _ac55 = _ac55 + 1; else _ad55 = _ad55 + 1; end;
if P_RESPOND1 >= .50 then do; if _Ftarget = '1' then _aa50 = _aa50 + 1; else _ab50 = _ab50 + 1; end; else do; if _Ftarget = '1' then _ac50 = _ac50 + 1; else _ad50 = _ad50 + 1; end;
if P_RESPOND1 >= .45 then do; if _Ftarget = '1' then _aa45 = _aa45 + 1; else _ab45 = _ab45 + 1; end; else do; if _Ftarget = '1' then _ac45 = _ac45 + 1; else _ad45 = _ad45 + 1; end;
if P_RESPOND1 >= .40 then do; if _Ftarget = '1' then _aa40 = _aa40 + 1; else _ab40 = _ab40 + 1; end; else do; if _Ftarget = '1' then _ac40 = _ac40 + 1; else _ad40 = _ad40 + 1; end;
if P_RESPOND1 >= .35 then do; if _Ftarget = '1' then _aa35 = _aa35 + 1; else _ab35 = _ab35 + 1; end; else do; if _Ftarget = '1' then _ac35 = _ac35 + 1; else _ad35 = _ad35 + 1; end;
if P_RESPOND1 >= .30 then do; if _Ftarget = '1' then _aa30 = _aa30 + 1; else _ab30 = _ab30 + 1; end; else do; if _Ftarget = '1' then _ac30 = _ac30 + 1; else _ad30 = _ad30 + 1; end;
if P_RESPOND1 >= .25 then do; if _Ftarget = '1' then _aa25 = _aa25 + 1; else _ab25 = _ab25 + 1; end; else do; if _Ftarget = '1' then _ac25 = _ac25 + 1; else _ad25 = _ad25 + 1; end;
if P_RESPOND1 >= .20 then do; if _Ftarget = '1' then _aa20 = _aa20 + 1; else _ab20 = _ab20 + 1; end; else do; if _Ftarget = '1' then _ac20 = _ac20 + 1; else _ad20 = _ad20 + 1; end;
if P_RESPOND1 >= .15 then do; if _Ftarget = '1' then _aa15 = _aa15 + 1; else _ab15 = _ab15 + 1; end; else do; if _Ftarget = '1' then _ac15 = _ac15 + 1; else _ad15 = _ad15 + 1; end;
if P_RESPOND1 >= .10 then do; if _Ftarget = '1' then _aa10 = _aa10 + 1; else _ab10 = _ab10 + 1; end; else do; if _Ftarget = '1' then _ac10 = _ac10 + 1; else _ad10 = _ad10 + 1; end;
if P_RESPOND1 >= .05 then do; if _Ftarget = '1' then _aa05 = _aa05 + 1; else _ab05 = _ab05 + 1; end; else do; if _Ftarget = '1' then _ac05 = _ac05 + 1; else _ad05 = _ad05 + 1; end;
if P_RESPOND1 >= 0 then do; if _Ftarget = '1' then _aa00 = _aa00 + 1; else _ab00 = _ab00 + 1; end; else do; if _Ftarget = '1' then _ac00 = _ac00 + 1; else _ad00 = _ad00 + 1; end; /* process target level 2 */ if P_RESPOND0 = 1 then do; if _Ftarget = '0' then _ba99 = _ba99 + 1; else _bb99 = _bb99 + 1; end; else do; if _Ftarget = '0' then _bc99 = _bc99 + 1; else _bd99 = _bd99 + 1; end;
if P_RESPOND0 >= .95 then do; if _Ftarget = '0' then _ba95 = _ba95 + 1; else _bb95 = _bb95 + 1; end; else do; if _Ftarget = '0' then _bc95 = _bc95 + 1; else _bd95 = _bd95 + 1; end;
if P_RESPOND0 >= .90 then do; if _Ftarget = '0' then _ba90 = _ba90 + 1; else _bb90 = _bb90 + 1; end; else do; if _Ftarget = '0' then _bc90 = _bc90 + 1; else _bd90 = _bd90 + 1; end;
if P_RESPOND0 >= .85 then do; if _Ftarget = '0' then _ba85 = _ba85 + 1; else _bb85 = _bb85 + 1; end; else do; if _Ftarget = '0' then _bc85 = _bc85 + 1; else _bd85 = _bd85 + 1; end;
if P_RESPOND0 >= .80 then do; if _Ftarget = '0' then _ba80 = _ba80 + 1; else _bb80 = _bb80 + 1; end; else do; if _Ftarget = '0' then _bc80 = _bc80 + 1; else _bd80 = _bd80 + 1; end;
if P_RESPOND0 >= .75 then do; if _Ftarget = '0' then _ba75 = _ba75 + 1; else _bb75 = _bb75 + 1; end; else do; if _Ftarget = '0' then _bc75 = _bc75 + 1; else _bd75 = _bd75 + 1; end;
if P_RESPOND0 >= .70 then do; if _Ftarget = '0' then _ba70 = _ba70 + 1; else _bb70 = _bb70 + 1; end; else do; if _Ftarget = '0' then _bc70 = _bc70 + 1; else _bd70 = _bd70 + 1; end;
if P_RESPOND0 >= .65 then do; if _Ftarget = '0' then _ba65 = _ba65 + 1; else _bb65 = _bb65 + 1; end; else do; if _Ftarget = '0' then _bc65 = _bc65 + 1; else _bd65 = _bd65 + 1; end;
if P_RESPOND0 >= .60 then do; if _Ftarget = '0' then _ba60 = _ba60 + 1; else _bb60 = _bb60 + 1; end; else do; if _Ftarget = '0' then _bc60 = _bc60 + 1; else _bd60 = _bd60 + 1; end;
if P_RESPOND0 >= .55 then do; if _Ftarget = '0' then _ba55 = _ba55 + 1; else _bb55 = _bb55 + 1; end; else do; if _Ftarget = '0' then _bc55 = _bc55 + 1; else _bd55 = _bd55 + 1; end;
if P_RESPOND0 >= .50 then do; if _Ftarget = '0' then _ba50 = _ba50 + 1; else _bb50 = _bb50 + 1; end; else do; if _Ftarget = '0' then _bc50 = _bc50 + 1; else _bd50 = _bd50 + 1; end;
if P_RESPOND0 >= .45 then do; if _Ftarget = '0' then _ba45 = _ba45 + 1; else _bb45 = _bb45 + 1; end; else do; if _Ftarget = '0' then _bc45 = _bc45 + 1; else _bd45 = _bd45 + 1; end;
if P_RESPOND0 >= .40 then do; if _Ftarget = '0' then _ba40 = _ba40 + 1; else _bb40 = _bb40 + 1; end; else do; if _Ftarget = '0' then _bc40 = _bc40 + 1; else _bd40 = _bd40 + 1; end;
if P_RESPOND0 >= .35 then do; if _Ftarget = '0' then _ba35 = _ba35 + 1; else _bb35 = _bb35 + 1; end; else do; if _Ftarget = '0' then _bc35 = _bc35 + 1; else _bd35 = _bd35 + 1; end;
if P_RESPOND0 >= .30 then do; if _Ftarget = '0' then _ba30 = _ba30 + 1; else _bb30 = _bb30 + 1; end; else do; if _Ftarget = '0' then _bc30 = _bc30 + 1; else _bd30 = _bd30 + 1; end;
if P_RESPOND0 >= .25 then do; if _Ftarget = '0' then _ba25 = _ba25 + 1; else _bb25 = _bb25 + 1; end; else do; if _Ftarget = '0' then _bc25 = _bc25 + 1; else _bd25 = _bd25 + 1; end;
if P_RESPOND0 >= .20 then do; if _Ftarget = '0' then _ba20 = _ba20 + 1; else _bb20 = _bb20 + 1; end; else do; if _Ftarget = '0' then _bc20 = _bc20 + 1; else _bd20 = _bd20 + 1; end;
if P_RESPOND0 >= .15 then do; if _Ftarget = '0' then _ba15 = _ba15 + 1; else _bb15 = _bb15 + 1; end; else do; if _Ftarget = '0' then _bc15 = _bc15 + 1; else _bd15 = _bd15 + 1; end;
if P_RESPOND0 >= .10 then do; if _Ftarget = '0' then _ba10 = _ba10 + 1; else _bb10 = _bb10 + 1; end; else do; if _Ftarget = '0' then _bc10 = _bc10 + 1; else _bd10 = _bd10 + 1; end;
if P_RESPOND0 >= .05 then do; if _Ftarget = '0' then _ba05 = _ba05 + 1; else _bb05 = _bb05 + 1; end; else do; if _Ftarget = '0' then _bc05 = _bc05 + 1; else _bd05 = _bd05 + 1; end;
if P_RESPOND0 >= 0 then do; if _Ftarget = '0' then _ba00 = _ba00 + 1; else _bb00 = _bb00 + 1; end; else do; if _Ftarget = '0' then _bc00 = _bc00 + 1; else _bd00 = _bd00 + 1; end; if last_obn then do; _thresh=100;_lvlord='A'; _actual='1'; _predict='1'; _freq=_aa99; output; _actual='1'; _predict='0'; _freq=_ac99; output; _actual='0'; _predict='1'; _freq=_ab99; output; _actual='0'; _predict='0'; _freq=_ad99; output;
_thresh=95; _actual='1'; _predict='1'; _freq=_aa95; output; _actual='1'; _predict='0'; _freq=_ac95; output; _actual='0'; _predict='1'; _freq=_ab95; output; _actual='0'; _predict='0'; _freq=_ad95; output;
_thresh=90; _actual='1'; _predict='1'; _freq=_aa90; output; _actual='1'; _predict='0'; _freq=_ac90; output; _actual='0'; _predict='1'; _freq=_ab90; output; _actual='0'; _predict='0'; _freq=_ad90; output;
_thresh=85; _actual='1'; _predict='1'; _freq=_aa85; output; _actual='1'; _predict='0'; _freq=_ac85; output; _actual='0'; _predict='1'; _freq=_ab85; output; _actual='0'; _predict='0'; _freq=_ad85; output;
_thresh=80; _actual='1'; _predict='1'; _freq=_aa80; output; _actual='1'; _predict='0'; _freq=_ac80; output; _actual='0'; _predict='1'; _freq=_ab80; output; _actual='0'; _predict='0'; _freq=_ad80; output;
_thresh=75; _actual='1'; _predict='1'; _freq=_aa75; output; _actual='1'; _predict='0'; _freq=_ac75; output; _actual='0'; _predict='1'; _freq=_ab75; output; _actual='0'; _predict='0'; _freq=_ad75; output;
_thresh=70; _actual='1'; _predict='1'; _freq=_aa70; output; _actual='1'; _predict='0'; _freq=_ac70; output; _actual='0'; _predict='1'; _freq=_ab70; output; _actual='0'; _predict='0'; _freq=_ad70; output;
_thresh=65; _actual='1'; _predict='1'; _freq=_aa65; output; _actual='1'; _predict='0'; _freq=_ac65; output; _actual='0'; _predict='1'; _freq=_ab65; output; _actual='0'; _predict='0';_freq=_ad65; output;
_thresh=60; _actual='1'; _predict='1'; _freq=_aa60; output; _actual='1'; _predict='0'; _freq=_ac60; output; _actual='0'; _predict='1'; _freq=_ab60; output; _actual='0'; _predict='0';_freq=_ad60; output;
_thresh=55; _actual='1'; _predict='1'; _freq=_aa55; output; _actual='1'; _predict='0'; _freq=_ac55; output; _actual='0'; _predict='1'; _freq=_ab55; output; _actual='0'; _predict='0'; _freq=_ad55; output;
_thresh=50; _actual='1'; _predict='1'; _freq=_aa50; output; _actual='1'; _predict='0'; _freq=_ac50; output; _actual='0'; _predict='1'; _freq=_ab50; output; _actual='0'; _predict='0'; _freq=_ad50; output;
_thresh=45; _actual='1'; _predict='1'; _freq=_aa45; output; _actual='1'; _predict='0'; _freq=_ac45; output; _actual='0'; _predict='1'; _freq=_ab45; output; _actual='0'; _predict='0'; _freq=_ad45; output;
_thresh=40; _actual='1'; _predict='1'; _freq=_aa40; output; _actual='1'; _predict='0'; _freq=_ac40; output; _actual='0'; _predict='1'; _freq=_ab40; output; _actual='0'; _predict='0'; _freq=_ad40; output;
_thresh=35; _actual='1'; _predict='1'; _freq=_aa35; output; _actual='1'; _predict='0'; _freq=_ac35; output; _actual='0'; _predict='1'; _freq=_ab35; output; _actual='0'; _predict='0'; _freq=_ad35; output;
_thresh=30; _actual='1'; _predict='1'; _freq=_aa30; output; _actual='1'; _predict='0'; _freq=_ac30; output; _actual='0'; _predict='1'; _freq=_ab30; output; _actual='0'; _predict='0'; _freq=_ad30; output;
_thresh=25; _actual='1'; _predict='1'; _freq=_aa25; output; _actual='1'; _predict='0'; _freq=_ac25; output; _actual='0'; _predict='1'; _freq=_ab25; output; _actual='0'; _predict='0'; _freq=_ad25; output;
_thresh=20; _actual='1'; _predict='1'; _freq=_aa20; output; _actual='1'; _predict='0'; _freq=_ac20; output; _actual='0'; _predict='1'; _freq=_ab20; output; _actual='0'; _predict='0'; _freq=_ad20; output;
_thresh=15; _actual='1'; _predict='1'; _freq=_aa15; output; _actual='1'; _predict='0'; _freq=_ac15; output; _actual='0'; _predict='1'; _freq=_ab15; output; _actual='0'; _predict='0'; _freq=_ad15; output;
_thresh=10; _actual='1'; _predict='1'; _freq=_aa10; output; _actual='1'; _predict='0'; _freq=_ac10; output; _actual='0'; _predict='1'; _freq=_ab10; output; _actual='0'; _predict='0'; _freq=_ad10; output;
_thresh= 5; _actual='1'; _predict='1'; _freq=_aa05; output; _actual='1'; _predict='0'; _freq=_ac05; output; _actual='0'; _predict='1'; _freq=_ab05; output; _actual='0'; _predict='0'; _freq=_ad05; output;
_thresh= 0; _actual='1'; _predict='1'; _freq=_aa00; output; _actual='1'; _predict='0'; _freq=_ac00; output; _actual='0'; _predict='1'; _freq=_ab00; output; _actual='0'; _predict='0'; _freq=_ad00; output; _thresh=100;_lvlord='B'; _actual='1'; _predict='1'; _freq=_bd99; output; _actual='1'; _predict='0'; _freq=_bb99; output; _actual='0'; _predict='1'; _freq=_bc99; output; _actual='0'; _predict='0'; _freq=_ba99; output;
_thresh=95; _actual='1'; _predict='1'; _freq=_bd95; output; _actual='1'; _predict='0'; _freq=_bb95; output; _actual='0'; _predict='1'; _freq=_bc95; output; _actual='0'; _predict='0'; _freq=_ba95; output;
_thresh=90; _actual='1'; _predict='1'; _freq=_bd90; output; _actual='1'; _predict='0'; _freq=_bb90; output; _actual='0'; _predict='1'; _freq=_bc90; output; _actual='0'; _predict='0'; _freq=_ba90; output;
_thresh=85; _actual='1'; _predict='1'; _freq=_bd85; output; _actual='1'; _predict='0'; _freq=_bb85; output; _actual='0'; _predict='1'; _freq=_bc85; output; _actual='0'; _predict='0'; _freq=_ba85; output;
_thresh=80; _actual='1'; _predict='1'; _freq=_bd80; output; _actual='1'; _predict='0'; _freq=_bb80; output; _actual='0'; _predict='1'; _freq=_bc80; output; _actual='0'; _predict='0'; _freq=_ba80; output;
_thresh=75; _actual='1'; _predict='1'; _freq=_bd75; output; _actual='1'; _predict='0'; _freq=_bb75; output; _actual='0'; _predict='1'; _freq=_bc75; output; _actual='0'; _predict='0'; _freq=_ba75; output;
_thresh=70; _actual='1'; _predict='1'; _freq=_bd70; output; _actual='1'; _predict='0'; _freq=_bb70; output; _actual='0'; _predict='1'; _freq=_bc70; output; _actual='0'; _predict='0'; _freq=_ba70; output;
_thresh=65; _actual='1'; _predict='1'; _freq=_bd65; output; _actual='1'; _predict='0'; _freq=_bb65; output; _actual='0'; _predict='1'; _freq=_bc65; output; _actual='0'; _predict='0'; _freq=_ba65; output;
_thresh=60; _actual='1'; _predict='1'; _freq=_bd60; output; _actual='1'; _predict='0'; _freq=_bb60; output; _actual='0'; _predict='1'; _freq=_bc60; output; _actual='0'; _predict='0'; _freq=_ba60; output;
_thresh=55; _actual='1'; _predict='1'; _freq=_bd55; output; _actual='1'; _predict='0'; _freq=_bb55; output; _actual='0'; _predict='1'; _freq=_bc55; output; _actual='0'; _predict='0'; _freq=_ba55; output;
_thresh=50; _actual='1'; _predict='1'; _freq=_bd50; output; _actual='1'; _predict='0'; _freq=_bb50; output; _actual='0'; _predict='1'; _freq=_bc50; output; _actual='0'; _predict='0'; _freq=_ba50; output;
_thresh=45; _actual='1'; _predict='1'; _freq=_bd45; output; _actual='1'; _predict='0'; _freq=_bb45; output; _actual='0'; _predict='1'; _freq=_bc45; output; _actual='0'; _predict='0'; _freq=_ba45; output;
_thresh=40; _actual='1'; _predict='1'; _freq=_bd40; output; _actual='1'; _predict='0'; _freq=_bb40; output; _actual='0'; _predict='1'; _freq=_bc40; output; _actual='0'; _predict='0'; _freq=_ba40; output;
_thresh=35; _actual='1'; _predict='1'; _freq=_bd35; output; _actual='1'; _predict='0'; _freq=_bb35; output; _actual='0'; _predict='1'; _freq=_bc35; output; _actual='0'; _predict='0'; _freq=_ba35; output;
_thresh=30; _actual='1'; _predict='1'; _freq=_bd30; output; _actual='1'; _predict='0'; _freq=_bb30; output; _actual='0'; _predict='1'; _freq=_bc30; output; _actual='0'; _predict='0'; _freq=_ba30; output;
_thresh=25; _actual='1'; _predict='1'; _freq=_bd25; output; _actual='1'; _predict='0'; _freq=_bb25; output; _actual='0'; _predict='1'; _freq=_bc25; output; _actual='0'; _predict='0'; _freq=_ba25; output;
_thresh=20; _actual='1'; _predict='1'; _freq=_bd20; output; _actual='1'; _predict='0'; _freq=_bb20; output; _actual='0'; _predict='1'; _freq=_bc20; output; _actual='0'; _predict='0'; _freq=_ba20; output;
_thresh=15; _actual='1'; _predict='1'; _freq=_bd15; output; _actual='1'; _predict='0'; _freq=_bb15; output; _actual='0'; _predict='1'; _freq=_bc15; output; _actual='0'; _predict='0'; _freq=_ba15; output;
_thresh=10; _actual='1'; _predict='1'; _freq=_bd10; output; _actual='1'; _predict='0'; _freq=_bb10; output; _actual='0'; _predict='1'; _freq=_bc10; output; _actual='0'; _predict='0'; _freq=_ba10; output;
_thresh= 5; _actual='1'; _predict='1'; _freq=_bd05; output; _actual='1'; _predict='0'; _freq=_bb05; output; _actual='0'; _predict='1'; _freq=_bc05; output; _actual='0'; _predict='0'; _freq=_ba05; output;
_thresh= 0; _actual='1'; _predict='1'; _freq=_bd00; output; _actual='1'; _predict='0'; _freq=_bb00; output; _actual='0'; _predict='1'; _freq=_bc00; output; _actual='0'; _predict='0'; _freq=_ba00; output; end; run;
data EMDATA.STRNWQMI /view=EMDATA.STRNWQMI; set EMDATA.VIEW_IXA; run;
* _respc (_resp) : %Response; * _capc (_cap) : %Captured Response; * _liftc (_lift) : LIFT VALUE; * _profitc(_profit): PROFIT; data work.tmplift(rename=(_tool_=tool _decile=decile)); length _tool_ $10 modelid $8 modelnm $8 modelnam $20; set EMPROJ._A00002Y EMPROJ._A00002V EMPROJ._A000002 EMPROJ._A00002Z; modelnm = modelnam; run;
data tmplift; set tmplift; length decile2 $4 uptool $20 toolname $12; drop tmpdm tmpne tmptr tmpre tmpuser tmpelse uptool len; retain tmpdm 0 tmpne 0 tmptr 0 tmpre 0 tmpuser 0 tmpelse 0 rounded; if _n_ = 1 then do; if decile in(1,2,5,10,20,25,50) then rounded = 'Y'; else rounded = 'N'; end; if rounded = 'Y' then decile2 = left(putn(decile,3.)); else decile2 = left(putn(decile,4.1)); uptool = upcase(tool); if uptool =: 'DMINE' then tool = 'DMine'; else if uptool =: 'NEURAL' then tool = 'Neural'; else if (uptool =: 'DATA' or uptool =: 'DATASPLT' or uptool =: 'SPLT') then tool = 'Tree'; else if uptool =: 'REG' then tool = 'Reg'; else if uptool =: 'USER' then tool = 'User'; else if uptool ^= 'EXACT' and uptool ^= 'BASELINE' then do; toolname = tool; tool = substr(tool,1,6); end;
if toolname = '' then toolname = tool;
if tool = 'DMine' then do; tmpdm + 1; if tmpdm > 10 then tool = trim(tool) || '-' || left(putn(int((tmpdm-1)/10)+1,2.)); end; else if tool = 'Neural' then do; tmpne + 1; if tmpne > 10 then tool = trim(tool) || '-' || left(putn(int((tmpne-1)/10)+1,2.)); end; else if tool = 'Tree' then do; tmptr + 1; if tmptr > 10 then tool = trim(tool) || '-' || left(putn(int((tmptr-1)/10)+1,2.)); end; else if tool = 'Reg' then do; tmpre + 1; if tmpre > 10 then tool = trim(tool) || '-' || left(putn(int((tmpre-1)/10)+1,2.)); end; else if tool = 'User' then do; tmpuser + 1; if tmpuser > 10 then tool = trim(tool) || '-' || left(putn(int((tmpuser-1)/10)+1,2.)); end; else if uptool ^= 'EXACT' and uptool ^= 'BASELINE' then do; tmpelse + 1; if tmpelse > 10 then tool = trim(tool) || '-' || left(putn(int((tmpelse-1)/10)+1,2.)); end; run;
data _liftdat; set tmplift; drop decile2 _iscost0 modelnam; modelnm = modelnam; Label toolname = 'Modeling Tool' tool = 'Modeling Tool' modelid = 'Model ID' modelnm = 'Model Name' _eprofit = 'Expected Profit at Cutoff' _profit = 'Average Profit Per Observation' _profitc = 'Cumulative Profit Per Observation' _resp = 'Response Rate (%)' _cap = 'Captured Response Rate (%)' _lift = 'Lift Value' _roi = 'Return on Investment' _respc = 'Cumulative Response Rate (%)' _capc = 'Cumulative Captured Response Rate (%)' _liftc = 'Cumulative Lift Value' _roic = 'Cumulative Return on Investment' _gcount = 'Number of Observations in each Group' decile = 'Percentile' _cutoff = 'Posterior Probability Cutoff (Event)'; Format _resp 7.3 _cap 7.3 _lift 9.3 _respc 7.3 _capc 7.3 _liftc 9.3 _cutoff 7.3 _gcount 15.2 _roi 12.5 _roic 12.5; run;
%put &sysrc; |
| 4. USER DEFINED MODEL | |
|
/******************************************* * * BEGIN: SAS Code Node * NODE : SAS Code [T1GGRMJ5] * EVENT: RUN; * */ /* * CONSTANT MACROS */
%let _LPFLAG = 0; %let _LPNDX = 1; %let _EVENT = _exec; %let _ERR = 0; %let _FMTSEARCH= (EMPROJ WORK LIBRARY SAMPSIO.EMFMT); %let _PLIB = EMPROJ; /*---- All non-rejected variables ----*/ %let _VARS = ID RESPOND AGE INCOME SEX MARRIED FICO OWNHOME LOC CLIMATE BUY6 BUY12 BUY18 VALUE24 ORGSRC DISCBUY RETURN24 COA6 C1 C2 C3 C4 C5 C6 C7 PURCHTOT; /*---- inputs ----*/ %let _INPUTS = AGE INCOME SEX MARRIED FICO OWNHOME LOC CLIMATE BUY6 BUY12 BUY18 VALUE24 ORGSRC DISCBUY RETURN24 COA6 C1 C2 C3 C4 C5 C6 C7 PURCHTOT;
/*---- interval inputs ----*/ %let _INTRVL =AGE INCOME FICO VALUE24 C1 C2 C3 C4 C5 C6 C7 PURCHTOT;
/*---- class inputs ----*/ %let _CLASS =SEX MARRIED OWNHOME LOC CLIMATE BUY6 BUY12 BUY18 ORGSRC DISCBUY RETURN24 COA6;
/*---- nominal inputs ----*/ %let _NOMINAL =LOC CLIMATE ORGSRC ;
/*---- binary inputs ----*/ %let _BINARY =SEX MARRIED OWNHOME DISCBUY RETURN24 COA6; /*---- ordinal inputs ----*/
%let _ORDINAL = BUY6 BUY12 BUY18;
/*---- input variable formats ----*/ %let _FORMATS = BEST12. BEST12. $1. BEST12. BEST12. BEST12. $1. $2. BEST12. BEST12. BEST12. BEST12. $1. BEST12. BEST12. BEST12. BEST12. BEST12. BEST12. BEST12. BEST12. BEST12. BEST12. BEST12.;
/*---- id variables ----*/ %let _ID =ID;
/*---- cost variables ----*/ %let _COST =; /*---- freq variables ----*/ %let _FREQ =; /*---- trial variables ----*/ %let _TRIAL =; /*---- predict variables ----*/ %let _PREDICT =; /*---- sequence variables ----*/ %let _SEQUENC =;
/*---- targets ----*/ %let _TARGETS =RESPOND;
/*---- target measurement(s) ----*/ %let _TGMEAS =BINARY;
/*---- rejected variables ----*/ %let _REJECTS =;
%let _DLIB = EMDATA;
/* * IMPORTED DATA SET MACROS BY ROLE */ %let _TRAIN = EMDATA.VIEW_IXA; %let _VALID =; %let _TEST =; %let _SCORE =;
/* * IMPORTED DATA SET MACROS BY INDEX */ %let _mac_1 = EMDATA.VIEW_IXA; /* * DMDB MACROS */ %let _DMDB =; %let _DMDBCAT=; /* * EXPORTED DATA SET MACROS */ %let _TRA= EMDATA.XTR_IWQ9; /* * PROGRAM STATEMENTS */ data EMDATA.VIEW_CZP / view=EMDATA.VIEW_CZP; set EMSAMPLE.BUYTEST; run;
proc dmdb data=EMDATA.VIEW_CZP out=_null_ dmdbcat=EMPROJ.dm_DGM00010 normlen=32 maxlevel=513; id ID; class RESPOND(Desc) SEX(Asc) MARRIED(Asc) OWNHOME(Asc) LOC(Asc) CLIMATE(Asc) BUY6(Asc) BUY12(Asc) BUY18(Asc) ORGSRC(Asc) DISCBUY(Asc) RETURN24(Asc) COA6(Asc); var AGE INCOME FICO VALUE24 C1 C2 C3 C4 C5 C6 C7 PURCHTOT; target RESPOND; run;
* Create data view with dmdb name; proc dmreg data=EMDATA.VIEW_CZP dmdbcat=EMPROJ.dm_DGM00010 outest=EMPROJ.DMRGX1OF(label="DMREG Parameter Estimates for node T3BJX7BA"); class RESPOND BUY12 BUY18 BUY6 CLIMATE COA6 DISCBUY LOC MARRIED ORGSRC OWNHOME RETURN24 SEX; model RESPOND = AGE BUY12 BUY18 BUY6 C1 C2 C3 C4 C5 C6 C7 CLIMATE COA6 DISCBUY FICO INCOME LOC MARRIED ORGSRC OWNHOME PURCHTOT RETURN24 SEX VALUE24 / coding=DEVIATION error = BINOMIAL link=LOGIT nodesignprint; nloptions maxtime = 604800 absfconv = 0 1 absgconv = 0.00001 1 absxconv = 1E-8 1 fconv = 0 1 gconv = 1E-6 1; score data=&_TRAIN out=&_TRA(label="Assessment data set for TRAIN" keep= P_RESPOND1 RESPOND rename=(P_RESPOND1=P_HAT)) ; run; quit; /* * * END: SAS Code : [T1GGRMJ5] * *******************************************/
data EMPROJ.SMP_XTUZ(drop=_II3PCE1); retain _II3PCE1 0; set EMDATA.XTR_IWQ9; if ranuni(0) < (2000-_II3PCE1) / (10000-_n_+1) then do; _II3PCE1 = _II3PCE1 + 1; output; end; run;
proc sql; create view EMDATA.EXDFG4QE as select XTR_IWQ9.P_HAT label='Predicted: RESPOND=1' format=BEST12. , XTR_IWQ9.RESPOND label='' format=BEST12. from EMDATA.XTR_IWQ9; run; quit;
proc sql; create view EMPROJ.SMPSOB7G as select XTR_IWQ9.P_HAT label='Predicted: RESPOND=1' format=BEST12. , XTR_IWQ9.RESPOND label='' format=BEST12. from EMPROJ.SMP_XTUZ; run; quit;
data EMDATA.STRNX7FK; set EMDATA.EXDFG4QE; label P_RESPOND1="Predicted: RESPOND=1"; P_RESPOND1 = P_HAT;
label P_RESPOND0="Predicted: RESPOND=0"; P_RESPOND0 = 1- P_RESPOND1;
label F_RESPOND="From:RESPOND"; F_RESPOND = substr(left(put(RESPOND,BEST12.)),1, min(16,length(left(put(RESPOND,BEST12.))))); F_RESPOND = upcase(F_RESPOND);
label I_RESPOND="Into:RESPOND"; if max(P_RESPOND1,P_RESPOND0)=P_RESPOND1 then I_RESPOND = "1"; else if max(P_RESPOND1,P_RESPOND0)=P_RESPOND0 then I_RESPOND = "0"; run; quit;
proc freq data=EMDATA.STRNX7FK; table F_RESPOND*I_RESPOND / out=EMPROJ.APIY8FA7 outpct; run;
data EMPROJ.RESPOND_(type=PROFIT label=RESPOND); LENGTH RESPOND $%DMNORLEN; input RESPOND $1-%DMNORLEN _DEC1 @; label _DEC1="1"; cards; 1 1 0 0 ; run; quit;
data work._DECDBG_; set EMPROJ.RESPOND_; run; quit;
proc decide data=EMDATA.STRNX7FK; target RESPOND; posterior P_RESPOND1 P_RESPOND0; decision decisiondata= EMPROJ.RESPOND_ decvars=_DEC1; code metabase = EMPROJ.T0F2PNAW.APIEZYW1 residuals; run; quit;
data EMDATA.STRNX7FK; set EMDATA.EXDFG4QE; label P_RESPOND1="Predicted: RESPOND=1"; P_RESPOND1 = P_HAT; label P_RESPOND0="Predicted: RESPOND=0"; P_RESPOND0 = 1- P_RESPOND1; label F_RESPOND="From:RESPOND"; F_RESPOND = substr(left(put(RESPOND,BEST12.)),1, min(16,length(left(put(RESPOND,BEST12.))))); F_RESPOND = upcase(F_RESPOND); label I_RESPOND="Into:RESPOND"; if max(P_RESPOND1,P_RESPOND0)=P_RESPOND1 then I_RESPOND = "1"; else if max(P_RESPOND1,P_RESPOND0)=P_RESPOND0 then I_RESPOND = "0"; *** Warning Variable; length _warn_ $4; label _warn_ = 'Warnings'; drop _decwarn; _decwarn = 0;
*** Check Posterior Probabilities; if not (n( P_RESPOND1 ) & (0 <= P_RESPOND1 ) & n( P_RESPOND0 ) & (0 <= P_RESPOND0 ) ) then do; _decwarn = 1; substr(_warn_,3,1) = 'P'; P_RESPOND1 = .; P_RESPOND0 = .; goto _demi; end; else if not (P_RESPOND1 <= 1 & P_RESPOND0 <= 1) then do; substr(_warn_,3,1) = 'P'; end; drop _sum; _sum = P_RESPOND1 + P_RESPOND0 ; if _sum > 4.135903E-25 then do; P_RESPOND1 = P_RESPOND1 / _sum; P_RESPOND0 = P_RESPOND0 / _sum; end;
*** Decision Processing; label D_RESPOND_ = 'Decision: RESPOND' ; label EP_RESPOND_ = 'Expected Profit: RESPOND' ; label BP_RESPOND_ = 'Best Profit: RESPOND' ; label CP_RESPOND_ = 'Computed Profit: RESPOND' ;
length D_RESPOND_ $ 5;
*** Initialize to Missing if Target Used; _demi:;
D_RESPOND_ = ' '; EP_RESPOND_ = .; BP_RESPOND_ = .; CP_RESPOND_ = .;
if _decwarn then goto _deex;
*** Compute Expected Consequences and Choose Decision; _decnum = 1; drop _decnum;
D_RESPOND_ = '1' ; EP_RESPOND_ = P_RESPOND1 * 1 + P_RESPOND0 * 0;
*** Decision Matrix; array _dema [2,1] _temporary_ ( /* row 1 */ 1 /* row 2 */ 0 );
*** Normalize Target Value; length _targnor $ %DMNORLEN; drop _targnor; length _format $200; drop _format; _format = put( RESPOND , BEST12. ); %DMNORMCP(_format,_targnor);
*** Find Index of Target Category; drop _tarnum; select( _targnor ); when('1' ) _tarnum = 1; when('0' ) _tarnum = 2; otherwise _tarnum = 0; end; if _tarnum <= 0 then goto _deex;
*** Computed Consequence of Chosen Decision; CP_RESPOND_ = _dema [_tarnum,_decnum];
*** Best Possible Consequence of Any Decision without Cost; array _debe [2] _temporary_ ( 1 0); BP_RESPOND_ = _debe [_tarnum];
_deex:; *** End Decision Processing ; run; quit;
proc contents data=EMDATA.STRNX7FK; run; quit;
data EMPROJ._A000062; set EMDATA.EXDFG4QE; label P_RESPOND1="Predicted: RESPOND=1"; P_RESPOND1 = P_HAT; label P_RESPOND0="Predicted: RESPOND=0"; P_RESPOND0 = 1- P_RESPOND1; label F_RESPOND="From:RESPOND"; F_RESPOND = substr(left(put(RESPOND,BEST12.)),1, min(16,length(left(put(RESPOND,BEST12.))))); F_RESPOND = upcase(F_RESPOND); label I_RESPOND="Into:RESPOND"; if max(P_RESPOND1,P_RESPOND0)=P_RESPOND1 then I_RESPOND = "1"; else if max(P_RESPOND1,P_RESPOND0)=P_RESPOND0 then I_RESPOND = "0"; *** Warning Variable; length _warn_ $4; label _warn_ = 'Warnings'; drop _decwarn; _decwarn = 0;
*** Check Posterior Probabilities; if not (n( P_RESPOND1 ) & (0 <= P_RESPOND1 ) & n( P_RESPOND0 ) & (0 <= P_RESPOND0 ) ) then do; _decwarn = 1; substr(_warn_,3,1) = 'P'; P_RESPOND1 = .; P_RESPOND0 = .; goto _demi; end; else if not (P_RESPOND1 <= 1 & P_RESPOND0 <= 1) then do; substr(_warn_,3,1) = 'P'; end; drop _sum; _sum = P_RESPOND1 + P_RESPOND0 ; if _sum > 4.135903E-25 then do; P_RESPOND1 = P_RESPOND1 / _sum; P_RESPOND0 = P_RESPOND0 / _sum; end;
*** Decision Processing; label D_RESPOND_ = 'Decision: RESPOND' ; label EP_RESPOND_ = 'Expected Profit: RESPOND' ; label BP_RESPOND_ = 'Best Profit: RESPOND' ; label CP_RESPOND_ = 'Computed Profit: RESPOND' ;
length D_RESPOND_ $ 5;
*** Initialize to Missing if Target Used; _demi:;
D_RESPOND_ = ' '; EP_RESPOND_ = .; BP_RESPOND_ = .; CP_RESPOND_ = .;
if _decwarn then goto _deex;
*** Compute Expected Consequences and Choose Decision; _decnum = 1; drop _decnum;
D_RESPOND_ = '1' ; EP_RESPOND_ = P_RESPOND1 * 1 + P_RESPOND0 * 0;
*** Decision Matrix; array _dema [2,1] _temporary_ ( /* row 1 */ 1 /* row 2 */ 0 );
*** Normalize Target Value; length _targnor $ %DMNORLEN; drop _targnor; length _format $200; drop _format; _format = put( RESPOND , BEST12. ); %DMNORMCP(_format,_targnor);
*** Find Index of Target Category; drop _tarnum; select( _targnor ); when('1' ) _tarnum = 1; when('0' ) _tarnum = 2; otherwise _tarnum = 0; end; if _tarnum <= 0 then goto _deex;
*** Computed Consequence of Chosen Decision; CP_RESPOND_ = _dema [_tarnum,_decnum];
*** Best Possible Consequence of Any Decision without Cost; array _debe [2] _temporary_ ( 1 0); BP_RESPOND_ = _debe [_tarnum];
_deex:; *** End Decision Processing ; run; quit;
data EMPROJ.SMP_ST5B(drop=_IXDH6F7); retain _IXDH6F7 0; set EMDATA.STRNX7FK; if ranuni(0) < (2000-_IXDH6F7) / (10000-_n_+1) then do; _IXDH6F7 = _IXDH6F7 + 1; output; end; run;
data EMPROJ._000tran(keep=_cost _aprofit _e_prob _e_count) EMPROJ._A00005Q(keep=_nprofit _nobs _pmiss) EMPROJ._A000063(keep= RESPOND P_RESPOND1 P_HAT P_RESPOND1 P_RESPOND0 EP_RESPOND_ BP_RESPOND_ CP_RESPOND_ _eprofit _cost _aprofit _warn_ _e_count _e_prob); set EMPROJ._A000062 end=_lastobn; length _aprofit 8 _Ftarget $%DMNORLEN; _cost = 0; _eprofit = EP_RESPOND_; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.)))); if (_Ftarget = '' or _Ftarget = '.') and (NOT _lastobn) then delete; _e_prob = P_RESPOND1; if _Ftarget = '1' then do; _e_count = 1; end; else if _Ftarget = '0' then do; _e_count = 0; end; _aprofit = CP_RESPOND_; _ncount + 1; output EMPROJ._000tran EMPROJ._A000063; if _e_count > 0 then _nprofit + 1; if _eprofit = . then _pmiss + 1; if _lastobn then do; _nobs = _ncount; _pmiss = _pmiss/_n_; put _pmiss= _nobs= _nprofit=; output EMPROJ._A00005Q; end; run;
data EMPROJ._A000064; set EMPROJ._A000063; drop _eprofit _cost _aprofit _freq_ _freqadj _e_: ic_: ep_: bp_: cp_: el_: bl_: cl_: ; drop _c000000; if _c000000 < 5000 then do; if ( (10000-_N_) * ranuni(12345) ) <= (5000-_c000000) then do; _c000000+1; output; end; end; run;
proc sort data=EMPROJ._A000063 ; by descending _e_prob; run;
data EMPROJ._A00005O(keep=_tool_ _decile _cutoff _eprofit _cap _lift _resp _capc _liftc _respc _gcount version); set EMPROJ._A000063 end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7; retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _resp9 _respc9 _cap9 _capc9 _lift9 _liftc9; rename _e_prob = _cutoff; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "User Defined"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _e_prob) < 1E-7 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_p = _e_prob; _tgcount = _tgcount + 1; if _e_count > 0 then do; _tcount = _tcount + 1; end; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; end; else do; _ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do; do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end; _count = _gcount * _ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; end; else do; _tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; link do_out; end;
_ave = _tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end; if _tgcount <= 0.00001 then _tgcount = 0; _tcount = _tgcount * _tave; end; return;
do_out: _nobns = _nobns + _n_per_q;
_q_out = _q_out + 1; _decile = 100 * _q_out / nquants; _cap = _n_per_q * _ave * 100 / n_y_1; _lift = _ave / ( n_y_1 / sumfreq); _resp = _ave * 100;
_countc = _countc + _n_per_q * _ave; _capc = (_countc / n_y_1) * 100; _liftc = _capc / _decile; _respc = (_countc / _nobns) * 100; if ^_lastobs then _eprofit = _prev_ep; if _q_out > 1 then do; if abs(_resp - _resp9 ) < 1E-7 then _resp = _resp9 ; if abs(_respc - _respc9 ) < 1E-7 then _respc = _respc9 ; if abs(_cap - _cap9 ) < 1E-7 then _cap = _cap9 ; if abs(_capc - _capc9 ) < 1E-7 then _capc = _capc9 ; if abs(_lift - _lift9 ) < 1E-7 then _lift = _lift9 ; if abs(_liftc - _liftc9 ) < 1E-7 then _liftc = _liftc9 ; end; if _q_out = 1 then do; _respc = _resp; _capc = _cap; _liftc = _lift; end; if ^_lastobs then _e_prob = _prev_ep; output;
if _q_out = 1 then do; _resp9 = _resp; _respc9 = _respc; _cap9 = _cap; _capc9 = _capc; _lift9 = _lift; _liftc9 = _liftc; end; else do; if abs(_resp - _resp9 ) > 1E-7 then _resp9 = _resp ; if abs(_respc - _respc9 ) > 1E-7 then _respc9 = _respc ; if abs(_cap - _cap9 ) > 1E-7 then _cap9 = _cap ; if abs(_capc - _capc9 ) > 1E-7 then _capc9 = _capc ; if abs(_lift - _lift9 ) > 1E-7 then _lift9 = _lift ; if abs(_liftc - _liftc9 ) > 1E-7 then _liftc9 = _liftc ; end; return; run;
proc sort data=EMPROJ._A000063 ; by descending _eprofit; run; data EMPROJ._000LFT2(keep= _profit _roi _profitc _roic Tprofit Tprofitc proftype _iscost0); set EMPROJ._A000063 end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7;
retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _prev_ep 0; /* EP from previous observation. */ retain _prof2 0 _cost2 0 _tprof2 0 _tcost2 0; retain _profitc 0 _roic 0; retain _profit9 _proftc9 _roi9 _roic9; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "User Defined"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _eprofit) < 0.00001 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; _prof2 + _tprof2; _tprof2 = 0; _cost2 + _tcost2; _tcost2 = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_ep = _cur_ep; _eprofit = _cur_ep; _prev_p = _eprofit; _tgcount = _tgcount + 1; if _aprofit > 0.5 then do; _tcount = _tcount + 1; end; _tprof2 + _aprofit; _tcost2 + _cost; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; _p_ave = _prof2/_gcount; _c_ave = _cost2/_gcount; end; else do; _ave = 0; _p_ave = 0; _c_ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do; do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end; _count = _gcount * _ave; _prof2 = _gcount * _p_ave; _cost2 = _gcount * _c_ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; _p_tave = _tprof2/_tgcount; _c_tave = _tcost2/_tgcount; end; else do; _tave = 0; _p_tave = 0; _c_tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _p_ave = (_gcount * _p_ave + (_n_per_q - _gcount) * _p_tave) / _n_per_q; _c_ave = (_gcount * _c_ave + (_n_per_q - _gcount) * _c_tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; _prof2 = 0; _cost2 = 0; link do_out; end;
_ave = _tave; _p_ave = _p_tave; _c_ave = _c_tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0; _tcount = _tgcount * _tave; _tprof2 = _tgcount * _p_tave; _tcost2 = _tgcount * _c_tave; end; return;
do_out: _nobns = _nobns + _n_per_q;
_q_out = _q_out + 1; _decile = 100 * _q_out / nquants; if ^_lastobs then _eprofit = _prev_ep; /* non-cummulative average profit, total profit, and average roi */ _eprofit = _prev_ep; _profit = _p_ave; Tprofit = _p_ave * _n_per_q; if _c_ave ^= 0 and _c_ave ^= . then do; _roi = _p_ave/_c_ave; _iscost0 = 'N'; end; else do; _roi = .; _iscost0 = 'Y'; end; /* cummulative average profit, total profit, and average roi */ if _roic ^= . and _roic ^= 0 then _costc = _profitc/_roic; else _costc = 0; _profitc = ((_profitc * (_nobns - _n_per_q)) + (_p_ave * _n_per_q)) /_nobns; Tprofitc = _profitc * _nobns; if (_costc + _c_ave * _n_per_q) ^= 0 then _roic = Tprofitc / (_costc * (_nobns - _n_per_q) + _c_ave * _n_per_q); else _roic = .; if _q_out > 1 then do; if abs(_profit - _profit9) < 0.00001 then _profit = _profit9 ; if abs(_profitc- _proftc9) < 0.00001 then _profitc = _proftc9 ;
if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) < 1E-7 then _roi = _roi9 ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) < 1E-7 then _roic = _roic9 ; end; end; if _q_out = 1 then do; _profitc = _profit; _roic = _roi; end; output;
if _q_out = 1 then do; _profit9 = _profit; _proftc9 = _profitc; _roi9 = _roi; _roic9 = _roic; end; else do; if abs(_profit - _profit9) > 0.00001 then _profit9 = _profit ; if abs(_profitc- _proftc9) > 0.00001 then _proftc9 = _profitc;
if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) > 1E-7 then _roi9 = _roi ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) > 1E-7 then _roic9 = _roic ; end; end; return; run;
data EMPROJ._A00005O; merge EMPROJ._A00005O EMPROJ._000LFT2; run;
proc sort data=EMPROJ._000tran ; by descending _e_count; run;
data EMPROJ._A00005S(keep= _tool_ _decile _cutoff _eprofit _cap _lift _resp _capc _liftc _respc _gcount version); set EMPROJ._000tran end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7;
retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _resp9 _respc9 _cap9 _capc9 _lift9 _liftc9; rename _e_prob = _cutoff; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Exact"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _e_count) < 1E-7 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_p = _e_count; _tgcount = _tgcount + 1; if _e_count > 0 then do; _tcount = _tcount + 1; end; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; end; else do; _ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do; do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q; link do_out; end; _count = _gcount * _ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; end; else do; _tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; link do_out; end;
_ave = _tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0;
_tcount = _tgcount * _tave; end; return;
do_out: _nobns = _nobns + _n_per_q; _q_out = _q_out + 1; _decile = 100 * _q_out / nquants; _cap = _n_per_q * _ave * 100 / n_y_1; _lift = _ave / ( n_y_1 / sumfreq); _resp = _ave * 100;
_countc = _countc + _n_per_q * _ave; _capc = (_countc / n_y_1) * 100; _liftc = _capc / _decile; _respc = (_countc / _nobns) * 100; if ^_lastobs then _eprofit = _prev_ep; if _q_out > 1 then do; if abs(_resp - _resp9 ) < 1E-7 then _resp = _resp9 ; if abs(_respc - _respc9 ) < 1E-7 then _respc = _respc9 ; if abs(_cap - _cap9 ) < 1E-7 then _cap = _cap9 ; if abs(_capc - _capc9 ) < 1E-7 then _capc = _capc9 ; if abs(_lift - _lift9 ) < 1E-7 then _lift = _lift9 ; if abs(_liftc - _liftc9 ) < 1E-7 then _liftc = _liftc9 ; end; if _q_out = 1 then do; _respc = _resp; _capc = _cap; _liftc = _lift; end; _e_prob = .; if ^_lastobs then _e_prob = _prev_ep; output;
if _q_out = 1 then do; _resp9 = _resp; _respc9 = _respc; _cap9 = _cap; _capc9 = _capc; _lift9 = _lift; _liftc9 = _liftc; end; else do; if abs(_resp - _resp9 ) > 1E-7 then _resp9 = _resp ; if abs(_respc - _respc9 ) > 1E-7 then _respc9 = _respc ; if abs(_cap - _cap9 ) > 1E-7 then _cap9 = _cap ; if abs(_capc - _capc9 ) > 1E-7 then _capc9 = _capc ; if abs(_lift - _lift9 ) > 1E-7 then _lift9 = _lift ; if abs(_liftc - _liftc9 ) > 1E-7 then _liftc9 = _liftc ; end; return; run;
proc sort data=EMPROJ._000tran ; by descending _aprofit; run; data EMPROJ._000LFT2(keep= _profit _roi _profitc _roic Tprofit Tprofitc proftype _iscost0); set EMPROJ._000tran end = _lastobs; length _tool_ $8 _iscost0 $1 proftype $7;
retain _nobns 0; /* sum of freqs of obs output */ retain _gcount 0; /* sum of freqs of obs since last output */ retain _countc 0; /* sum of freqs of obs with y=1 output */ retain _count 0; /* sum freqs obs with y=1 since last output.*/
retain _prev_p 0; /* P from previous observation. */ retain _tgcount 0; /* sum of freqs of obs with p = previous p */ retain _tcount 0; /* sum freq obs with y=1 and p = previous p */
retain _q_out 0; /* n quantiles output */ retain _n_per_q 0; /* n obs per quantile */
retain n_y_1 0; retain sumfreq 0; retain nquants 0; retain version ; retain _tool_ proftype; retain _prev_ep 0; /* EP from previous obn */ retain _prev_ep 0; /* EP from previous observation. */ retain _prof2 0 _cost2 0 _tprof2 0 _tcost2 0; retain _profitc 0 _roic 0; retain _profit9 _proftc9 _roi9 _roic9; drop _gcount; rename _n_per_q = _gcount;
_eprofit = _eprofit; /* force it to the front */ _cur_ep = _eprofit; /*--- CANNOT CHECK TIE ON FIRST OBS. JUST COLLECT STATS -----*/ if _n_ = 1 then do; _prev_ep = _eprofit; sumfreq = 10000; n_y_1 = 767; nquants = 10; _n_per_q = sumfreq / nquants;
_tool_ = "Exact"; proftype = "PROFIT"; version = 3;
link do_accum;
/* in case the assessed data set has only one obn */ if _lastobs then do; link out_put; stop; end; return; end; /*--- IF P IS TIED WITH P IN PREVIOUS OBS, JUST ACCUMULATE ------*/ if (_prev_p - _aprofit) < 0.00001 then do; link do_accum; return; end;
/*--- P IS NOT TIED WITH PREVIOUS P. TIME TO OUTPUT? -----------*/ if (floor((_nobns + _gcount + _tgcount)/_n_per_q) > _q_out) then do; link out_put; end; /*--- MERGE STATS ON RECENT TIED VALUES INTO GENERAL STATS -------*/ _count + _tcount; _tcount = 0; _gcount + _tgcount; _tgcount = 0; _prof2 + _tprof2; _tprof2 = 0; _cost2 + _tcost2; _tcost2 = 0; /*--- ACCUMULATE NEW OBSERVATION INTO FIRST OF POSSIBLE TIES -----*/ link do_accum; _prev_ep = _cur_ep; return;
do_accum: /* ACUMULATE NEW OBS INTO TIED VALUES */ _prev_ep = _cur_ep; _prev_p = _aprofit; _tgcount = _tgcount + 1; if _aprofit > 0.5 then do; _tcount = _tcount + 1; end; _tprof2 + _aprofit; _tcost2 + _cost; /*--- IF LAST OBSERVATION, OUTPUT IT -------------------------*/ if _lastobs then do; link out_put; stop; end; return;
out_put: if _gcount > 0.00001 then do; _ave = _count/_gcount; _p_ave = _prof2/_gcount; _c_ave = _cost2/_gcount; end; else do; _ave = 0; _p_ave = 0; _c_ave = 0; end;
if _gcount >= _n_per_q or _lastobs and _tgcount < 0.00001 then do; do while( _gcount >= _n_per_q - 0.00001); _gcount = _gcount - _n_per_q;
link do_out; end;
_count = _gcount * _ave; _prof2 = _gcount * _p_ave; _cost2 = _gcount * _c_ave; end;
if _gcount + _tgcount >= _n_per_q or (_lastobs and _gcount + _tgcount >= 0.00001) then do; /* _tgcount must be > 0, otherwise still in above loop. */ if _tgcount > 0.00001 then do; _tave = _tcount/_tgcount; _p_tave = _tprof2/_tgcount; _c_tave = _tcost2/_tgcount; end; else do; _tave = 0; _p_tave = 0; _c_tave = 0; end;
if _gcount > 0 then do; _ave = (_gcount * _ave + (_n_per_q - _gcount) * _tave) / _n_per_q; _p_ave = (_gcount * _p_ave + (_n_per_q - _gcount) * _p_tave) / _n_per_q; _c_ave = (_gcount * _c_ave + (_n_per_q - _gcount) * _c_tave) / _n_per_q; _tgcount = _tgcount - (_n_per_q - _gcount); _gcount = 0; _count = 0; _prof2 = 0; _cost2 = 0; link do_out; end;
_ave = _tave; _p_ave = _p_tave; _c_ave = _c_tave; do while(_tgcount >= _n_per_q - 0.00001); _tgcount = _tgcount - _n_per_q; link do_out; end;
if _tgcount <= 0.00001 then _tgcount = 0; _tcount = _tgcount * _tave; _tprof2 = _tgcount * _p_tave; _tcost2 = _tgcount * _c_tave; end; return;
do_out: _nobns = _nobns + _n_per_q;
_q_out = _q_out + 1; _decile = 100 * _q_out / nquants; if ^_lastobs then _eprofit = _prev_ep; /* non-cummulative average profit, total profit, and average roi */ _eprofit = _prev_ep; _profit = _p_ave; Tprofit = _p_ave * _n_per_q; if _c_ave ^= 0 and _c_ave ^= . then do; _roi = _p_ave/_c_ave; _iscost0 = 'N'; end; else do; _roi = .; _iscost0 = 'Y'; end; /* cummulative average profit, total profit, and average roi */ if _roic ^= . and _roic ^= 0 then _costc = _profitc/_roic; else _costc = 0; _profitc = ((_profitc * (_nobns - _n_per_q)) + (_p_ave * _n_per_q)) /_nobns; Tprofitc = _profitc * _nobns; if (_costc + _c_ave * _n_per_q) ^= 0 then _roic = Tprofitc / (_costc * (_nobns - _n_per_q) + _c_ave * _n_per_q); else _roic = .; if _q_out > 1 then do; if abs(_profit - _profit9) < 0.00001 then _profit = _profit9 ; if abs(_profitc- _proftc9) < 0.00001 then _profitc = _proftc9 ; if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) < 1E-7 then _roi = _roi9 ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) < 1E-7 then _roic = _roic9 ; end; end; if _q_out = 1 then do; _profitc = _profit; _roic = _roi; end; _e_prob = .; output;
if _q_out = 1 then do; _profit9 = _profit; _proftc9 = _profitc; _roi9 = _roi; _roic9 = _roic; end; else do; if abs(_profit - _profit9) > 0.00001 then _profit9 = _profit ; if abs(_profitc- _proftc9) > 0.00001 then _proftc9 = _profitc;
if _roi ^= . and _roi9 ^= . then do; if abs(_roi - _roi9 ) > 1E-7 then _roi9 = _roi ; end;
if _roic ^= . and _roic9 ^= . then do; if abs(_roic - _roic9 ) > 1E-7 then _roic9 = _roic ; end; end; return; run; data EMPROJ._A00005S; merge EMPROJ._A00005S EMPROJ._000LFT2; run;
data EMPROJ._A00005R; set EMPROJ._A00005O end=_lastobs; length modelid $8; drop _resp _respc _profit _profitc _roi _roic x _decile; drop _lift _liftc cont_cap big_diff tprofit tprofitc; rename _resp2 = _resp; rename _respc2 = _respc; rename _profit2 = _profit; rename _proftc2 = _profitc; rename _roi2 = _roi; rename _roic2 = _roic; rename _lift2 = _lift; rename _liftc2 = _liftc; rename tprofit2 = tprofit; rename tproftc2 = tprofitc;
retain cont_cap; retain big_diff 0; modelid = 'Baseline'; _tool_ = 'Baseline'; modelnam = 'Baseline';
if _n_ = 1 then cont_cap = _cap;
if abs(cont_cap - _cap) > 0.00001 then big_diff = 1;
if _lastobs then do x = 1 to 10; _eprofit = .; _cutoff = .; _resp2 = _respc; _respc2 = _respc;
if big_diff then _cap = 100 / 10; else _cap = cont_cap;
_capc = (100 / 10) * x; _lift2 = _liftc; _liftc2 = _liftc; _profit2 = _profitc; _proftc2 = _profitc; tprofit2 = _profitc * _gcount; tproftc2 = (_profitc * _gcount) * x; _roi2 = _roic; _roic2 = _roic; output; end; run;
data EMPROJ._A00005R; merge EMPROJ._A00005O EMPROJ._A00005R; run; data EMPROJ._000tmp1(keep= _TARGET _OUTPUT); set EMPROJ._A000063; length _aTarget _pTarget $16; rename _pTarget=_OUTPUT _aTarget=_TARGET; _aTarget = left(trim(put(RESPOND,BEST12.))); if P_RESPOND1 >= P_RESPOND0 then _pTarget = '1'; else _pTarget = '0'; run;
proc freq data=EMPROJ._000tmp1(rename=(_target=target _output=output)) noprint; table target * output / out=EMPROJ._A00005V; table target /out=EMPROJ._000tmp3(keep=target count rename=(count=total)); quit;
data EMPROJ._A00005V(drop =total); merge EMPROJ._A00005V EMPROJ._000tmp3; by target; label lvl_per = 'Percent'; lvl_per = (count/total) * 100; run;
data EMPROJ._A00005V; set EMPROJ._A00005V; target = upcase(target); run;
proc sort data=EMPROJ._A00005V; by target output; run;
data EMPROJ._000tmp5(keep=target); set EMPROJ._A00005V; run;
proc sort data=EMPROJ._000tmp5 NODUP; by target; run;
data EMPROJ._000tmp6; length target $%DMNORLEN output $%DMNORLEN count 8 percent 8 lvl_per 8; target = 'X'; output='X'; count=0;percent=0; lvl_per=0; stop; run; proc sort data=EMPROJ._000tmp6; by target output; run;
proc sort data=EMPROJ._A00005V; by target output; run;
data EMPROJ._A00005V; update EMPROJ._000tmp6 EMPROJ._A00005V; by target output; run; /* proc datasets lib= EMPROJ nolist; delete _000tmp1 /mt=DATA; quit; proc datasets lib= EMPROJ nolist; delete _000tmp3 /mt=DATA; quit; proc datasets lib= EMPROJ nolist; delete _000tmp5 /mt=DATA; quit; */ data EMPROJ._A00005Z(keep=_tool _cutoff _avg _freq _lvlord rename=(_cutoff=cutoff _avg=avg _freq=freq _tool=tool _lvlord=lvlord)); set EMPROJ._A000063 end=last_obn; length _tool $15 _cutoff $2 _avg 8 _freq 8 _lvlord $1 _Ftarget $%DMNORLEN; drop _Ftarget; retain _afrq95 0 _afrq90 0 _afrq85 0 _afrq80 0 _afrq75 0 _afrq70 0 _afrq65 0 _afrq60 0 _afrq55 0 _afrq50 0 _afrq45 0 _afrq40 0 _afrq35 0 _afrq30 0 _afrq25 0 _afrq20 0 _afrq15 0 _afrq10 0 _afrq05 0
_acrt95 0 _acrt90 0 _acrt85 0 _acrt80 0 _acrt75 0 _acrt70 0 _acrt65 0 _acrt60 0 _acrt55 0 _acrt50 0 _acrt45 0 _acrt40 0 _acrt35 0 _acrt30 0 _acrt25 0 _acrt20 0 _acrt15 0 _acrt10 0 _acrt05 0 _bfrq95 0 _bfrq90 0 _bfrq85 0 _bfrq80 0 _bfrq75 0 _bfrq70 0 _bfrq65 0 _bfrq60 0 _bfrq55 0 _bfrq50 0 _bfrq45 0 _bfrq40 0 _bfrq35 0 _bfrq30 0 _bfrq25 0 _bfrq20 0 _bfrq15 0 _bfrq10 0 _bfrq05 0
_bcrt95 0 _bcrt90 0 _bcrt85 0 _bcrt80 0 _bcrt75 0 _bcrt70 0 _bcrt65 0 _bcrt60 0 _bcrt55 0 _bcrt50 0 _bcrt45 0 _bcrt40 0 _bcrt35 0 _bcrt30 0 _bcrt25 0 _bcrt20 0 _bcrt15 0 _bcrt10 0 _bcrt05 0;
_tool = "User Defined"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if _Ftarget = '1' then _acrt = 1; else _acrt = 0;
if P_RESPOND1 >= .95 then link A95; if P_RESPOND1 >= .90 then link A90; if P_RESPOND1 >= .85 then link A85; if P_RESPOND1 >= .80 then link A80; if P_RESPOND1 >= .75 then link A75; if P_RESPOND1 >= .70 then link A70; if P_RESPOND1 >= .65 then link A65; if P_RESPOND1 >= .60 then link A60; if P_RESPOND1 >= .55 then link A55; if P_RESPOND1 >= .50 then link A50; if P_RESPOND1 >= .45 then link A45; if P_RESPOND1 >= .40 then link A40; if P_RESPOND1 >= .35 then link A35; if P_RESPOND1 >= .30 then link A30; if P_RESPOND1 >= .25 then link A25; if P_RESPOND1 >= .20 then link A20; if P_RESPOND1 >= .15 then link A15; if P_RESPOND1 >= .10 then link A10; if P_RESPOND1 >= .05 then link A05; /* process target level 2 */ if _Ftarget = '0' then _bcrt = 1; else _bcrt = 0;
if P_RESPOND0 >= .95 then link B95; if P_RESPOND0 >= .90 then link B90; if P_RESPOND0 >= .85 then link B85; if P_RESPOND0 >= .80 then link B80; if P_RESPOND0 >= .75 then link B75; if P_RESPOND0 >= .70 then link B70; if P_RESPOND0 >= .65 then link B65; if P_RESPOND0 >= .60 then link B60; if P_RESPOND0 >= .55 then link B55; if P_RESPOND0 >= .50 then link B50; if P_RESPOND0 >= .45 then link B45; if P_RESPOND0 >= .40 then link B40; if P_RESPOND0 >= .35 then link B35; if P_RESPOND0 >= .30 then link B30; if P_RESPOND0 >= .25 then link B25; if P_RESPOND0 >= .20 then link B20; if P_RESPOND0 >= .15 then link B15; if P_RESPOND0 >= .10 then link B10; if P_RESPOND0 >= .05 then link B05; if last_obn then do; if _afrq95 > 0 then _aavg95 = _acrt95 / _afrq95; if _afrq90 > 0 then _aavg90 = _acrt90 / _afrq90; if _afrq85 > 0 then _aavg85 = _acrt85 / _afrq85; if _afrq80 > 0 then _aavg80 = _acrt80 / _afrq80; if _afrq75 > 0 then _aavg75 = _acrt75 / _afrq75; if _afrq70 > 0 then _aavg70 = _acrt70 / _afrq70; if _afrq65 > 0 then _aavg65 = _acrt65 / _afrq65; if _afrq60 > 0 then _aavg60 = _acrt60 / _afrq60; if _afrq55 > 0 then _aavg55 = _acrt55 / _afrq55; if _afrq50 > 0 then _aavg50 = _acrt50 / _afrq50; if _afrq45 > 0 then _aavg45 = _acrt45 / _afrq45; if _afrq40 > 0 then _aavg40 = _acrt40 / _afrq40; if _afrq35 > 0 then _aavg35 = _acrt35 / _afrq35; if _afrq30 > 0 then _aavg30 = _acrt30 / _afrq30; if _afrq25 > 0 then _aavg25 = _acrt25 / _afrq25; if _afrq20 > 0 then _aavg20 = _acrt20 / _afrq20; if _afrq15 > 0 then _aavg15 = _acrt15 / _afrq15; if _afrq10 > 0 then _aavg10 = _acrt10 / _afrq10; if _afrq05 > 0 then _aavg05 = _acrt05 / _afrq05; if _bfrq95 > 0 then _bavg95 = _bcrt95 / _bfrq95; if _bfrq90 > 0 then _bavg90 = _bcrt90 / _bfrq90; if _bfrq85 > 0 then _bavg85 = _bcrt85 / _bfrq85; if _bfrq80 > 0 then _bavg80 = _bcrt80 / _bfrq80; if _bfrq75 > 0 then _bavg75 = _bcrt75 / _bfrq75; if _bfrq70 > 0 then _bavg70 = _bcrt70 / _bfrq70; if _bfrq65 > 0 then _bavg65 = _bcrt65 / _bfrq65; if _bfrq60 > 0 then _bavg60 = _bcrt60 / _bfrq60; if _bfrq55 > 0 then _bavg55 = _bcrt55 / _bfrq55; if _bfrq50 > 0 then _bavg50 = _bcrt50 / _bfrq50; if _bfrq45 > 0 then _bavg45 = _bcrt45 / _bfrq45; if _bfrq40 > 0 then _bavg40 = _bcrt40 / _bfrq40; if _bfrq35 > 0 then _bavg35 = _bcrt35 / _bfrq35; if _bfrq30 > 0 then _bavg30 = _bcrt30 / _bfrq30; if _bfrq25 > 0 then _bavg25 = _bcrt25 / _bfrq25; if _bfrq20 > 0 then _bavg20 = _bcrt20 / _bfrq20; if _bfrq15 > 0 then _bavg15 = _bcrt15 / _bfrq15; if _bfrq10 > 0 then _bavg10 = _bcrt10 / _bfrq10; if _bfrq05 > 0 then _bavg05 = _bcrt05 / _bfrq05; _cutoff='95';_avg=_aavg95;_freq=_afrq95;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='90';_avg=_aavg90;_freq=_afrq90;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='85';_avg=_aavg85;_freq=_afrq85;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='80';_avg=_aavg80;_freq=_afrq80;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='75';_avg=_aavg75;_freq=_afrq75;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='70';_avg=_aavg70;_freq=_afrq70;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='65';_avg=_aavg65;_freq=_afrq65;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='60';_avg=_aavg60;_freq=_afrq60;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='55';_avg=_aavg55;_freq=_afrq55;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='50';_avg=_aavg50;_freq=_afrq50;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='45';_avg=_aavg45;_freq=_afrq45;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='40';_avg=_aavg40;_freq=_afrq40;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='35';_avg=_aavg35;_freq=_afrq35;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='30';_avg=_aavg30;_freq=_afrq30;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='25';_avg=_aavg25;_freq=_afrq25;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='20';_avg=_aavg20;_freq=_afrq20;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='15';_avg=_aavg15;_freq=_afrq15;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='10';_avg=_aavg10;_freq=_afrq10;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='05';_avg=_aavg05;_freq=_afrq05;_lvlord='A'; if _avg=. then _avg=0;output; _cutoff='95';_avg=_bavg95;_freq=_bfrq95;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='90';_avg=_bavg90;_freq=_bfrq90;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='85';_avg=_bavg85;_freq=_bfrq85;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='80';_avg=_bavg80;_freq=_bfrq80;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='75';_avg=_bavg75;_freq=_bfrq75;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='70';_avg=_bavg70;_freq=_bfrq70;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='65';_avg=_bavg65;_freq=_bfrq65;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='60';_avg=_bavg60;_freq=_bfrq60;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='55';_avg=_bavg55;_freq=_bfrq55;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='50';_avg=_bavg50;_freq=_bfrq50;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='45';_avg=_bavg45;_freq=_bfrq45;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='40';_avg=_bavg40;_freq=_bfrq40;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='35';_avg=_bavg35;_freq=_bfrq35;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='30';_avg=_bavg30;_freq=_bfrq30;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='25';_avg=_bavg25;_freq=_bfrq25;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='20';_avg=_bavg20;_freq=_bfrq20;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='15';_avg=_bavg15;_freq=_bfrq15;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='10';_avg=_bavg10;_freq=_bfrq10;_lvlord='B'; if _avg=. then _avg=0;output; _cutoff='05';_avg=_bavg05;_freq=_bfrq05;_lvlord='B'; if _avg=. then _avg=0;output; end; return; A95: _afrq95 = _afrq95 + 1; if _acrt = 1 then _acrt95 = _acrt95 + 1; return; A90: _afrq90 = _afrq90 + 1; if _acrt = 1 then _acrt90 = _acrt90 + 1; return; A85: _afrq85 = _afrq85 + 1; if _acrt = 1 then _acrt85 = _acrt85 + 1; return; A80: _afrq80 = _afrq80 + 1; if _acrt = 1 then _acrt80 = _acrt80 + 1; return; A75: _afrq75 = _afrq75 + 1; if _acrt = 1 then _acrt75 = _acrt75 + 1; return; A70: _afrq70 = _afrq70 + 1; if _acrt = 1 then _acrt70 = _acrt70 + 1; return; A65: _afrq65 = _afrq65 + 1; if _acrt = 1 then _acrt65 = _acrt65 + 1; return; A60: _afrq60 = _afrq60 + 1; if _acrt = 1 then _acrt60 = _acrt60 + 1; return; A55: _afrq55 = _afrq55 + 1; if _acrt = 1 then _acrt55 = _acrt55 + 1; return; A50: _afrq50 = _afrq50 + 1; if _acrt = 1 then _acrt50 = _acrt50 + 1; return; A45: _afrq45 = _afrq45 + 1; if _acrt = 1 then _acrt45 = _acrt45 + 1; return; A40: _afrq40 = _afrq40 + 1; if _acrt = 1 then _acrt40 = _acrt40 + 1; return; A35: _afrq35 = _afrq35 + 1; if _acrt = 1 then _acrt35 = _acrt35 + 1; return; A30: _afrq30 = _afrq30 + 1; if _acrt = 1 then _acrt30 = _acrt30 + 1; return; A25: _afrq25 = _afrq25 + 1; if _acrt = 1 then _acrt25 = _acrt25 + 1; return; A20: _afrq20 = _afrq20 + 1; if _acrt = 1 then _acrt20 = _acrt20 + 1; return; A15: _afrq15 = _afrq15 + 1; if _acrt = 1 then _acrt15 = _acrt15 + 1; return; A10: _afrq10 = _afrq10 + 1; if _acrt = 1 then _acrt10 = _acrt10 + 1; return; A05: _afrq05 = _afrq05 + 1; if _acrt = 1 then _acrt05 = _acrt05 + 1; return; B95: _bfrq95 = _bfrq95 + 1; if _bcrt = 1 then _bcrt95 = _bcrt95 + 1; return; B90: _bfrq90 = _bfrq90 + 1; if _bcrt = 1 then _bcrt90 = _bcrt90 + 1; return; B85: _bfrq85 = _bfrq85 + 1; if _bcrt = 1 then _bcrt85 = _bcrt85 + 1; return; B80: _bfrq80 = _bfrq80 + 1; if _bcrt = 1 then _bcrt80 = _bcrt80 + 1; return; B75: _bfrq75 = _bfrq75 + 1; if _bcrt = 1 then _bcrt75 = _bcrt75 + 1; return; B70: _bfrq70 = _bfrq70 + 1; if _bcrt = 1 then _bcrt70 = _bcrt70 + 1; return; B65: _bfrq65 = _bfrq65 + 1; if _bcrt = 1 then _bcrt65 = _bcrt65 + 1; return; B60: _bfrq60 = _bfrq60 + 1; if _bcrt = 1 then _bcrt60 = _bcrt60 + 1; return; B55: _bfrq55 = _bfrq55 + 1; if _bcrt = 1 then _bcrt55 = _bcrt55 + 1; return; B50: _bfrq50 = _bfrq50 + 1; if _bcrt = 1 then _bcrt50 = _bcrt50 + 1; return; B45: _bfrq45 = _bfrq45 + 1; if _bcrt = 1 then _bcrt45 = _bcrt45 + 1; return; B40: _bfrq40 = _bfrq40 + 1; if _bcrt = 1 then _bcrt40 = _bcrt40 + 1; return; B35: _bfrq35 = _bfrq35 + 1; if _bcrt = 1 then _bcrt35 = _bcrt35 + 1; return; B30: _bfrq30 = _bfrq30 + 1; if _bcrt = 1 then _bcrt30 = _bcrt30 + 1; return; B25: _bfrq25 = _bfrq25 + 1; if _bcrt = 1 then _bcrt25 = _bcrt25 + 1; return; B20: _bfrq20 = _bfrq20 + 1; if _bcrt = 1 then _bcrt20 = _bcrt20 + 1; return; B15: _bfrq15 = _bfrq15 + 1; if _bcrt = 1 then _bcrt15 = _bcrt15 + 1; return; B10: _bfrq10 = _bfrq10 + 1; if _bcrt = 1 then _bcrt10 = _bcrt10 + 1; return; B05: _bfrq05 = _bfrq05 + 1; if _bcrt = 1 then _bcrt05 = _bcrt05 + 1; return; run; data EMPROJ._000sroc(keep=_tool _se _sp _lvlord rename=(_se=se _sp=sp _tool=tool _lvlord=lvlord)); set EMPROJ._A000063 end=last_obn; length _tool $15 _lvlord $1 _Ftarget $%DMNORLEN; drop _Ftarget; retain _aa99 _ab99 _ac99 _ad99 _aa95 _ab95 _ac95 _ad95 _aa90 _ab90 _ac90 _ad90 _aa85 _ab85 _ac85 _ad85 _aa80 _ab80 _ac80 _ad80 _aa75 _ab75 _ac75 _ad75 _aa70 _ab70 _ac70 _ad70 _aa65 _ab65 _ac65 _ad65 _aa60 _ab60 _ac60 _ad60 _aa55 _ab55 _ac55 _ad55 _aa50 _ab50 _ac50 _ad50 _aa45 _ab45 _ac45 _ad45 _aa40 _ab40 _ac40 _ad40 _aa35 _ab35 _ac35 _ad35 _aa30 _ab30 _ac30 _ad30 _aa25 _ab25 _ac25 _ad25 _aa20 _ab20 _ac20 _ad20 _aa15 _ab15 _ac15 _ad15 _aa10 _ab10 _ac10 _ad10 _aa05 _ab05 _ac05 _ad05 _aa00 _ab00 _ac00 _ad00 _ba99 _bb99 _bc99 _bd99 _ba95 _bb95 _bc95 _bd95 _ba90 _bb90 _bc90 _bd90 _ba85 _bb85 _bc85 _bd85 _ba80 _bb80 _bc80 _bd80 _ba75 _bb75 _bc75 _bd75 _ba70 _bb70 _bc70 _bd70 _ba65 _bb65 _bc65 _bd65 _ba60 _bb60 _bc60 _bd60 _ba55 _bb55 _bc55 _bd55 _ba50 _bb50 _bc50 _bd50 _ba45 _bb45 _bc45 _bd45 _ba40 _bb40 _bc40 _bd40 _ba35 _bb35 _bc35 _bd35 _ba30 _bb30 _bc30 _bd30 _ba25 _bb25 _bc25 _bd25 _ba20 _bb20 _bc20 _bd20 _ba15 _bb15 _bc15 _bd15 _ba10 _bb10 _bc10 _bd10 _ba05 _bb05 _bc05 _bd05 _ba00 _bb00 _bc00 _bd00 0;
_tool = "User Defined"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if P_RESPOND1 = 1 then do; if _Ftarget = '1' then _aa99 = _aa99 + 1; else _ab99 = _ab99 + 1; end; else do; if _Ftarget = '1' then _ac99 = _ac99 + 1; else _ad99 = _ad99 + 1; end;
if P_RESPOND1 >= .95 then do; if _Ftarget = '1' then _aa95 = _aa95 + 1; else _ab95 = _ab95 + 1; end; else do; if _Ftarget = '1' then _ac95 = _ac95 + 1; else _ad95 = _ad95 + 1; end;
if P_RESPOND1 >= .90 then do; if _Ftarget = '1' then _aa90 = _aa90 + 1; else _ab90 = _ab90 + 1; end; else do; if _Ftarget = '1' then _ac90 = _ac90 + 1; else _ad90 = _ad90 + 1; end;
if P_RESPOND1 >= .85 then do; if _Ftarget = '1' then _aa85 = _aa85 + 1; else _ab85 = _ab85 + 1; end; else do; if _Ftarget = '1' then _ac85 = _ac85 + 1; else _ad85 = _ad85 + 1; end;
if P_RESPOND1 >= .80 then do; if _Ftarget = '1' then _aa80 = _aa80 + 1; else _ab80 = _ab80 + 1; end; else do; if _Ftarget = '1' then _ac80 = _ac80 + 1; else _ad80 = _ad80 + 1; end;
if P_RESPOND1 >= .75 then do; if _Ftarget = '1' then _aa75 = _aa75 + 1; else _ab75 = _ab75 + 1; end; else do; if _Ftarget = '1' then _ac75 = _ac75 + 1; else _ad75 = _ad75 + 1; end;
if P_RESPOND1 >= .70 then do; if _Ftarget = '1' then _aa70 = _aa70 + 1; else _ab70 = _ab70 + 1; end; else do; if _Ftarget = '1' then _ac70 = _ac70 + 1; else _ad70 = _ad70 + 1; end;
if P_RESPOND1 >= .65 then do; if _Ftarget = '1' then _aa65 = _aa65 + 1; else _ab65 = _ab65 + 1; end; else do; if _Ftarget = '1' then _ac65 = _ac65 + 1; else _ad65 = _ad65 + 1; end;
if P_RESPOND1 >= .60 then do; if _Ftarget = '1' then _aa60 = _aa60 + 1; else _ab60 = _ab60 + 1; end; else do; if _Ftarget = '1' then _ac60 = _ac60 + 1; else _ad60 = _ad60 + 1; end;
if P_RESPOND1 >= .55 then do; if _Ftarget = '1' then _aa55 = _aa55 + 1; else _ab55 = _ab55 + 1; end; else do; if _Ftarget = '1' then _ac55 = _ac55 + 1; else _ad55 = _ad55 + 1; end;
if P_RESPOND1 >= .50 then do; if _Ftarget = '1' then _aa50 = _aa50 + 1; else _ab50 = _ab50 + 1; end; else do; if _Ftarget = '1' then _ac50 = _ac50 + 1; else _ad50 = _ad50 + 1; end;
if P_RESPOND1 >= .45 then do; if _Ftarget = '1' then _aa45 = _aa45 + 1; else _ab45 = _ab45 + 1; end; else do; if _Ftarget = '1' then _ac45 = _ac45 + 1; else _ad45 = _ad45 + 1; end;
if P_RESPOND1 >= .40 then do; if _Ftarget = '1' then _aa40 = _aa40 + 1; else _ab40 = _ab40 + 1; end; else do; if _Ftarget = '1' then _ac40 = _ac40 + 1; else _ad40 = _ad40 + 1; end;
if P_RESPOND1 >= .35 then do; if _Ftarget = '1' then _aa35 = _aa35 + 1; else _ab35 = _ab35 + 1; end; else do; if _Ftarget = '1' then _ac35 = _ac35 + 1; else _ad35 = _ad35 + 1; end;
if P_RESPOND1 >= .30 then do; if _Ftarget = '1' then _aa30 = _aa30 + 1; else _ab30 = _ab30 + 1; end; else do; if _Ftarget = '1' then _ac30 = _ac30 + 1; else _ad30 = _ad30 + 1; end;
if P_RESPOND1 >= .25 then do; if _Ftarget = '1' then _aa25 = _aa25 + 1; else _ab25 = _ab25 + 1; end; else do; if _Ftarget = '1' then _ac25 = _ac25 + 1; else _ad25 = _ad25 + 1; end;
if P_RESPOND1 >= .20 then do; if _Ftarget = '1' then _aa20 = _aa20 + 1; else _ab20 = _ab20 + 1; end; else do; if _Ftarget = '1' then _ac20 = _ac20 + 1; else _ad20 = _ad20 + 1; end;
if P_RESPOND1 >= .15 then do; if _Ftarget = '1' then _aa15 = _aa15 + 1; else _ab15 = _ab15 + 1; end; else do; if _Ftarget = '1' then _ac15 = _ac15 + 1; else _ad15 = _ad15 + 1; end;
if P_RESPOND1 >= .10 then do; if _Ftarget = '1' then _aa10 = _aa10 + 1; else _ab10 = _ab10 + 1; end; else do; if _Ftarget = '1' then _ac10 = _ac10 + 1; else _ad10 = _ad10 + 1; end;
if P_RESPOND1 >= .05 then do; if _Ftarget = '1' then _aa05 = _aa05 + 1; else _ab05 = _ab05 + 1; end; else do; if _Ftarget = '1' then _ac05 = _ac05 + 1; else _ad05 = _ad05 + 1; end;
if P_RESPOND1 >= 0 then do; if _Ftarget = '1' then _aa00 = _aa00 + 1; else _ab00 = _ab00 + 1; end; /* process target level 2 */ if P_RESPOND0 = 1 then do; if _Ftarget = '0' then _ba99 = _ba99 + 1; else _bb99 = _bb99 + 1; end; else do; if _Ftarget = '0' then _bc99 = _bc99 + 1; else _bd99 = _bd99 + 1; end;
if P_RESPOND0 >= .95 then do; if _Ftarget = '0' then _ba95 = _ba95 + 1; else _bb95 = _bb95 + 1; end; else do; if _Ftarget = '0' then _bc95 = _bc95 + 1; else _bd95 = _bd95 + 1; end;
if P_RESPOND0 >= .90 then do; if _Ftarget = '0' then _ba90 = _ba90 + 1; else _bb90 = _bb90 + 1; end; else do; if _Ftarget = '0' then _bc90 = _bc90 + 1; else _bd90 = _bd90 + 1; end;
if P_RESPOND0 >= .85 then do; if _Ftarget = '0' then _ba85 = _ba85 + 1; else _bb85 = _bb85 + 1; end; else do; if _Ftarget = '0' then _bc85 = _bc85 + 1; else _bd85 = _bd85 + 1; end;
if P_RESPOND0 >= .80 then do; if _Ftarget = '0' then _ba80 = _ba80 + 1; else _bb80 = _bb80 + 1; end; else do; if _Ftarget = '0' then _bc80 = _bc80 + 1; else _bd80 = _bd80 + 1; end;
if P_RESPOND0 >= .75 then do; if _Ftarget = '0' then _ba75 = _ba75 + 1; else _bb75 = _bb75 + 1; end; else do; if _Ftarget = '0' then _bc75 = _bc75 + 1; else _bd75 = _bd75 + 1; end;
if P_RESPOND0 >= .70 then do; if _Ftarget = '0' then _ba70 = _ba70 + 1; else _bb70 = _bb70 + 1; end; else do; if _Ftarget = '0' then _bc70 = _bc70 + 1; else _bd70 = _bd70 + 1; end;
if P_RESPOND0 >= .65 then do; if _Ftarget = '0' then _ba65 = _ba65 + 1; else _bb65 = _bb65 + 1; end; else do; if _Ftarget = '0' then _bc65 = _bc65 + 1; else _bd65 = _bd65 + 1; end;
if P_RESPOND0 >= .60 then do; if _Ftarget = '0' then _ba60 = _ba60 + 1; else _bb60 = _bb60 + 1; end; else do; if _Ftarget = '0' then _bc60 = _bc60 + 1; else _bd60 = _bd60 + 1; end;
if P_RESPOND0 >= .55 then do; if _Ftarget = '0' then _ba55 = _ba55 + 1; else _bb55 = _bb55 + 1; end; else do; if _Ftarget = '0' then _bc55 = _bc55 + 1; else _bd55 = _bd55 + 1; end;
if P_RESPOND0 >= .50 then do; if _Ftarget = '0' then _ba50 = _ba50 + 1; else _bb50 = _bb50 + 1; end; else do; if _Ftarget = '0' then _bc50 = _bc50 + 1; else _bd50 = _bd50 + 1; end;
if P_RESPOND0 >= .45 then do; if _Ftarget = '0' then _ba45 = _ba45 + 1; else _bb45 = _bb45 + 1; end; else do; if _Ftarget = '0' then _bc45 = _bc45 + 1; else _bd45 = _bd45 + 1; end;
if P_RESPOND0 >= .40 then do; if _Ftarget = '0' then _ba40 = _ba40 + 1; else _bb40 = _bb40 + 1; end; else do; if _Ftarget = '0' then _bc40 = _bc40 + 1; else _bd40 = _bd40 + 1; end;
if P_RESPOND0 >= .35 then do; if _Ftarget = '0' then _ba35 = _ba35 + 1; else _bb35 = _bb35 + 1; end; else do; if _Ftarget = '0' then _bc35 = _bc35 + 1; else _bd35 = _bd35 + 1; end;
if P_RESPOND0 >= .30 then do; if _Ftarget = '0' then _ba30 = _ba30 + 1; else _bb30 = _bb30 + 1; end; else do; if _Ftarget = '0' then _bc30 = _bc30 + 1; else _bd30 = _bd30 + 1; end;
if P_RESPOND0 >= .25 then do; if _Ftarget = '0' then _ba25 = _ba25 + 1; else _bb25 = _bb25 + 1; end; else do; if _Ftarget = '0' then _bc25 = _bc25 + 1; else _bd25 = _bd25 + 1; end;
if P_RESPOND0 >= .20 then do; if _Ftarget = '0' then _ba20 = _ba20 + 1; else _bb20 = _bb20 + 1; end; else do; if _Ftarget = '0' then _bc20 = _bc20 + 1; else _bd20 = _bd20 + 1; end;
if P_RESPOND0 >= .15 then do; if _Ftarget = '0' then _ba15 = _ba15 + 1; else _bb15 = _bb15 + 1; end; else do; if _Ftarget = '0' then _bc15 = _bc15 + 1; else _bd15 = _bd15 + 1; end;
if P_RESPOND0 >= .10 then do; if _Ftarget = '0' then _ba10 = _ba10 + 1; else _bb10 = _bb10 + 1; end; else do; if _Ftarget = '0' then _bc10 = _bc10 + 1; else _bd10 = _bd10 + 1; end;
if P_RESPOND0 >= .05 then do; if _Ftarget = '0' then _ba05 = _ba05 + 1; else _bb05 = _bb05 + 1; end; else do; if _Ftarget = '0' then _bc05 = _bc05 + 1; else _bd05 = _bd05 + 1; end;
if P_RESPOND0 >= 0 then do; if _Ftarget = '0' then _ba00 = _ba00 + 1; else _bb00 = _bb00 + 1; end; /* else do; * will never get hee * if _Ftarget = '0' then _bc00 = _bc00 + 1; else _bd00 = _bd00 + 1; end; */ if last_obn then do; if (_aa99+_ac99)> 0 then _se = _aa99/(_aa99+_ac99); else _se = 0; if (_ab99+_ad99)> 0 then _sp = 1-(_ad99/(_ab99+_ad99)); else _sp = 0; _lvlord = 'A'; output;
if (_aa95+_ac95)> 0 then _se = _aa95/(_aa95+_ac95); else _se = 0; if (_ab95+_ad95)> 0 then _sp = 1-(_ad95/(_ab95+_ad95)); else _sp = 0; _lvlord = 'A'; output;
if (_aa90+_ac90)> 0 then _se = _aa90/(_aa90+_ac90); else _se = 0; if (_ab90+_ad90)> 0 then _sp = 1-(_ad90/(_ab90+_ad90)); else _sp = 0; _lvlord = 'A'; output;
if (_aa85+_ac85)> 0 then _se = _aa85/(_aa85+_ac85); else _se = 0; if (_ab85+_ad85)> 0 then _sp = 1-(_ad85/(_ab85+_ad85)); else _sp = 0; _lvlord = 'A'; output;
if (_aa80+_ac80)> 0 then _se = _aa80/(_aa80+_ac80); else _se = 0; if (_ab80+_ad80)> 0 then _sp = 1-(_ad80/(_ab80+_ad80)); else _sp = 0; _lvlord = 'A'; output;
if (_aa75+_ac75)> 0 then _se = _aa75/(_aa75+_ac75); else _se = 0; if (_ab75+_ad75)> 0 then _sp = 1-(_ad75/(_ab75+_ad75)); else _sp = 0; _lvlord = 'A'; output;
if (_aa70+_ac70)> 0 then _se = _aa70/(_aa70+_ac70); else _se = 0; if (_ab70+_ad70)> 0 then _sp = 1-(_ad70/(_ab70+_ad70)); else _sp = 0; _lvlord = 'A'; output;
if (_aa65+_ac65)> 0 then _se = _aa65/(_aa65+_ac65); else _se = 0; if (_ab65+_ad65)> 0 then _sp = 1-(_ad65/(_ab65+_ad65)); else _sp = 0; _lvlord = 'A'; output;
if (_aa60+_ac60)> 0 then _se = _aa60/(_aa60+_ac60); else _se = 0; if (_ab60+_ad60)> 0 then _sp = 1-(_ad60/(_ab60+_ad60)); else _sp = 0; _lvlord = 'A'; output;
if (_aa55+_ac55)> 0 then _se = _aa55/(_aa55+_ac55); else _se = 0; if (_ab55+_ad55)> 0 then _sp = 1-(_ad55/(_ab55+_ad55)); else _sp = 0; _lvlord = 'A'; output;
if (_aa50+_ac50)> 0 then _se = _aa50/(_aa50+_ac50); else _se = 0; if (_ab50+_ad50)> 0 then _sp = 1-(_ad50/(_ab50+_ad50)); else _sp = 0; _lvlord = 'A'; output;
if (_aa45+_ac45)> 0 then _se = _aa45/(_aa45+_ac45); else _se = 0; if (_ab45+_ad45)> 0 then _sp = 1-(_ad45/(_ab45+_ad45)); else _sp = 0; _lvlord = 'A'; output;
if (_aa40+_ac40)> 0 then _se = _aa40/(_aa40+_ac40); else _se = 0; if (_ab40+_ad40)> 0 then _sp = 1-(_ad40/(_ab40+_ad40)); else _sp = 0; _lvlord = 'A'; output;
if (_aa35+_ac35)> 0 then _se = _aa35/(_aa35+_ac35); else _se = 0; if (_ab35+_ad35)> 0 then _sp = 1-(_ad35/(_ab35+_ad35)); else _sp = 0; _lvlord = 'A'; output;
if (_aa30+_ac30)> 0 then _se = _aa30/(_aa30+_ac30); else _se = 0; if (_ab30+_ad30)> 0 then _sp = 1-(_ad30/(_ab30+_ad30)); else _sp = 0; _lvlord = 'A'; output;
if (_aa25+_ac25)> 0 then _se = _aa25/(_aa25+_ac25); else _se = 0; if (_ab25+_ad25)> 0 then _sp = 1-(_ad25/(_ab25+_ad25)); else _sp = 0; _lvlord = 'A'; output;
if (_aa20+_ac20)> 0 then _se = _aa20/(_aa20+_ac20); else _se = 0; if (_ab20+_ad20)> 0 then _sp = 1-(_ad20/(_ab20+_ad20)); else _sp = 0; _lvlord = 'A'; output;
if (_aa15+_ac15)> 0 then _se = _aa15/(_aa15+_ac15); else _se = 0; if (_ab15+_ad15)> 0 then _sp = 1-(_ad15/(_ab15+_ad15)); else _sp = 0; _lvlord = 'A'; output;
if (_aa10+_ac10)> 0 then _se = _aa10/(_aa10+_ac10); else _se = 0; if (_ab10+_ad10)> 0 then _sp = 1-(_ad10/(_ab10+_ad10)); else _sp = 0; _lvlord = 'A'; output;
if (_aa05+_ac05)> 0 then _se = _aa05/(_aa05+_ac05); else _se = 0; if (_ab05+_ad05)> 0 then _sp = 1-(_ad05/(_ab05+_ad05)); else _sp = 0; _lvlord = 'A'; output;
_se=1; _sp=1; _lvlord = 'A'; output; if (_ba99+_bc99)> 0 then _se = _ba99/(_ba99+_bc99); else _se = 0; if (_bb99+_bd99)> 0 then _sp = 1-(_bd99/(_bb99+_bd99)); else _sp = 0; _lvlord = 'B'; output;
if (_ba95+_bc95)> 0 then _se = _ba95/(_ba95+_bc95); else _se = 0; if (_bb95+_bd95)> 0 then _sp = 1-(_bd95/(_bb95+_bd95)); else _sp = 0; _lvlord = 'B'; output;
if (_ba90+_bc90)> 0 then _se = _ba90/(_ba90+_bc90); else _se = 0; if (_bb90+_bd90)> 0 then _sp = 1-(_bd90/(_bb90+_bd90)); else _sp = 0; _lvlord = 'B'; output;
if (_ba85+_bc85)> 0 then _se = _ba85/(_ba85+_bc85); else _se = 0; if (_bb85+_bd85)> 0 then _sp = 1-(_bd85/(_bb85+_bd85)); else _sp = 0; _lvlord = 'B'; output;
if (_ba80+_bc80)> 0 then _se = _ba80/(_ba80+_bc80); else _se = 0; if (_bb80+_bd80)> 0 then _sp = 1-(_bd80/(_bb80+_bd80)); else _sp = 0; _lvlord = 'B'; output;
if (_ba75+_bc75)> 0 then _se = _ba75/(_ba75+_bc75); else _se = 0; if (_bb75+_bd75)> 0 then _sp = 1-(_bd75/(_bb75+_bd75)); else _sp = 0; _lvlord = 'B'; output;
if (_ba70+_bc70)> 0 then _se = _ba70/(_ba70+_bc70); else _se = 0; if (_bb70+_bd70)> 0 then _sp = 1-(_bd70/(_bb70+_bd70)); else _sp = 0; _lvlord = 'B'; output;
if (_ba65+_bc65)> 0 then _se = _ba65/(_ba65+_bc65); else _se = 0; if (_bb65+_bd65)> 0 then _sp = 1-(_bd65/(_bb65+_bd65)); else _sp = 0; _lvlord = 'B'; output;
if (_ba60+_bc60)> 0 then _se = _ba60/(_ba60+_bc60); else _se = 0; if (_bb60+_bd60)> 0 then _sp = 1-(_bd60/(_bb60+_bd60)); else _sp = 0; _lvlord = 'B'; output;
if (_ba55+_bc55)> 0 then _se = _ba55/(_ba55+_bc55); else _se = 0; if (_bb55+_bd55)> 0 then _sp = 1-(_bd55/(_bb55+_bd55)); else _sp = 0; _lvlord = 'B'; output;
if (_ba50+_bc50)> 0 then _se = _ba50/(_ba50+_bc50); else _se = 0; if (_bb50+_bd50)> 0 then _sp = 1-(_bd50/(_bb50+_bd50)); else _sp = 0; _lvlord = 'B'; output;
if (_ba45+_bc45)> 0 then _se = _ba45/(_ba45+_bc45); else _se = 0; if (_bb45+_bd45)> 0 then _sp = 1-(_bd45/(_bb45+_bd45)); else _sp = 0; _lvlord = 'B'; output;
if (_ba40+_bc40)> 0 then _se = _ba40/(_ba40+_bc40); else _se = 0; if (_bb40+_bd40)> 0 then _sp = 1-(_bd40/(_bb40+_bd40)); else _sp = 0; _lvlord = 'B'; output;
if (_ba35+_bc35)> 0 then _se = _ba35/(_ba35+_bc35); else _se = 0; if (_bb35+_bd35)> 0 then _sp = 1-(_bd35/(_bb35+_bd35)); else _sp = 0; _lvlord = 'B'; output;
if (_ba30+_bc30)> 0 then _se = _ba30/(_ba30+_bc30); else _se = 0; if (_bb30+_bd30)> 0 then _sp = 1-(_bd30/(_bb30+_bd30)); else _sp = 0; _lvlord = 'B'; output;
if (_ba25+_bc25)> 0 then _se = _ba25/(_ba25+_bc25); else _se = 0; if (_bb25+_bd25)> 0 then _sp = 1-(_bd25/(_bb25+_bd25)); else _sp = 0; _lvlord = 'B'; output;
if (_ba20+_bc20)> 0 then _se = _ba20/(_ba20+_bc20); else _se = 0; if (_bb20+_bd20)> 0 then _sp = 1-(_bd20/(_bb20+_bd20)); else _sp = 0; _lvlord = 'B'; output;
if (_ba15+_bc15)> 0 then _se = _ba15/(_ba15+_bc15); else _se = 0; if (_bb15+_bd15)> 0 then _sp = 1-(_bd15/(_bb15+_bd15)); else _sp = 0; _lvlord = 'B'; output;
if (_ba10+_bc10)> 0 then _se = _ba10/(_ba10+_bc10); else _se = 0; if (_bb10+_bd10)> 0 then _sp = 1-(_bd10/(_bb10+_bd10)); else _sp = 0; _lvlord = 'B'; output;
if (_ba05+_bc05)> 0 then _se = _ba05/(_ba05+_bc05); else _se = 0; if (_bb05+_bd05)> 0 then _sp = 1-(_bd05/(_bb05+_bd05)); else _sp = 0; _lvlord = 'B'; output;
_se=1; _sp=1; _lvlord = 'B'; output; /* replaced by the line above if (_ba00+_bc00)> 0 then _se = _ba00/(_ba00+_bc00); else _se = 0; if (_bb00+_bd00)> 0 then _sp = 1-(_bd00/(_bb00+_bd00)); else _sp = 0; _lvlord = 'B'; output; */ end; run;
proc sql; create view EMPROJ._000srv as select * from EMPROJ._000sroc where lvlord = "A"; quit;
proc sql; create view EMPROJ._000srv as select * from EMPROJ._000sroc where lvlord = "B"; quit;
data EMPROJ._A000060; set EMPROJ._000sroc; if _n_ = 1 then do; sp = 0; se = 0.77444589308996; lvlord = 'A'; output; sp = 0.1; se = 1; lvlord = 'A'; output; sp = 0.2; se = 1; lvlord = 'A'; output; sp = 0.3; se = 1; lvlord = 'A'; output; sp = 0.4; se = 1; lvlord = 'A'; output; sp = 0.5; se = 1; lvlord = 'A'; output; sp = 0.6; se = 1; lvlord = 'A'; output; sp = 0.7; se = 1; lvlord = 'A'; output; sp = 0.8; se = 1; lvlord = 'A'; output; sp = 0.9; se = 1; lvlord = 'A'; output; sp = 1; se = 1; lvlord = 'A'; output; sp = 0; se = 0; lvlord = 'B'; output; sp = 0.1; se = 1; lvlord = 'B'; output; sp = 0.2; se = 1; lvlord = 'B'; output; sp = 0.3; se = 1; lvlord = 'B'; output; sp = 0.4; se = 1; lvlord = 'B'; output; sp = 0.5; se = 1; lvlord = 'B'; output; sp = 0.6; se = 1; lvlord = 'B'; output; sp = 0.7; se = 1; lvlord = 'B'; output; sp = 0.8; se = 1; lvlord = 'B'; output; sp = 0.9; se = 1; lvlord = 'B'; output; sp = 1; se = 1; lvlord = 'B'; output; stop; end; run;
data EMPROJ._A000061(keep=_tool _thresh _freq _lvlord _predict _actual rename=(_thresh=thresh _predict=predict _actual=actual _freq=freq _tool=tool _lvlord=lvlord)); set EMPROJ._A000063 end=last_obn; length _tool $15 _lvlord $1 _predict _actual $%DMNORLEN _freq _thresh 8 _Ftarget $%DMNORLEN; drop _Ftarget; retain _aa99 _ab99 _ac99 _ad99 _aa95 _ab95 _ac95 _ad95 _aa90 _ab90 _ac90 _ad90 _aa85 _ab85 _ac85 _ad85 _aa80 _ab80 _ac80 _ad80 _aa75 _ab75 _ac75 _ad75 _aa70 _ab70 _ac70 _ad70 _aa65 _ab65 _ac65 _ad65 _aa60 _ab60 _ac60 _ad60 _aa55 _ab55 _ac55 _ad55 _aa50 _ab50 _ac50 _ad50 _aa45 _ab45 _ac45 _ad45 _aa40 _ab40 _ac40 _ad40 _aa35 _ab35 _ac35 _ad35 _aa30 _ab30 _ac30 _ad30 _aa25 _ab25 _ac25 _ad25 _aa20 _ab20 _ac20 _ad20 _aa15 _ab15 _ac15 _ad15 _aa10 _ab10 _ac10 _ad10 _aa05 _ab05 _ac05 _ad05 _aa00 _ab00 _ac00 _ad00 _ba99 _bb99 _bc99 _bd99 _ba95 _bb95 _bc95 _bd95 _ba90 _bb90 _bc90 _bd90 _ba85 _bb85 _bc85 _bd85 _ba80 _bb80 _bc80 _bd80 _ba75 _bb75 _bc75 _bd75 _ba70 _bb70 _bc70 _bd70 _ba65 _bb65 _bc65 _bd65 _ba60 _bb60 _bc60 _bd60 _ba55 _bb55 _bc55 _bd55 _ba50 _bb50 _bc50 _bd50 _ba45 _bb45 _bc45 _bd45 _ba40 _bb40 _bc40 _bd40 _ba35 _bb35 _bc35 _bd35 _ba30 _bb30 _bc30 _bd30 _ba25 _bb25 _bc25 _bd25 _ba20 _bb20 _bc20 _bd20 _ba15 _bb15 _bc15 _bd15 _ba10 _bb10 _bc10 _bd10 _ba05 _bb05 _bc05 _bd05 _ba00 _bb00 _bc00 _bd00 0 ;
_tool = "User Defined"; _Ftarget = left(trim(upcase(put(RESPOND,BEST12.))));
/* process target level 1 */ if P_RESPOND1 = 1 then do; if _Ftarget = '1' then _aa99 = _aa99 + 1; else _ab99 = _ab99 + 1; end; else do; if _Ftarget = '1' then _ac99 = _ac99 + 1; else _ad99 = _ad99 + 1; end;
if P_RESPOND1 >= .95 then do; if _Ftarget = '1' then _aa95 = _aa95 + 1; else _ab95 = _ab95 + 1; end; else do; if _Ftarget = '1' then _ac95 = _ac95 + 1; else _ad95 = _ad95 + 1; end;
if P_RESPOND1 >= .90 then do; if _Ftarget = '1' then _aa90 = _aa90 + 1; else _ab90 = _ab90 + 1; end; else do; if _Ftarget = '1' then _ac90 = _ac90 + 1; else _ad90 = _ad90 + 1; end;
if P_RESPOND1 >= .85 then do; if _Ftarget = '1' then _aa85 = _aa85 + 1; else _ab85 = _ab85 + 1; end; else do; if _Ftarget = '1' then _ac85 = _ac85 + 1; else _ad85 = _ad85 + 1; end;
if P_RESPOND1 >= .80 then do; if _Ftarget = '1' then _aa80 = _aa80 + 1; else _ab80 = _ab80 + 1; end; else do; if _Ftarget = '1' then _ac80 = _ac80 + 1; else _ad80 = _ad80 + 1; end;
if P_RESPOND1 >= .75 then do; if _Ftarget = '1' then _aa75 = _aa75 + 1; else _ab75 = _ab75 + 1; end; else do; if _Ftarget = '1' then _ac75 = _ac75 + 1; else _ad75 = _ad75 + 1; end;
if P_RESPOND1 >= .70 then do; if _Ftarget = '1' then _aa70 = _aa70 + 1; else _ab70 = _ab70 + 1; end; else do; if _Ftarget = '1' then _ac70 = _ac70 + 1; else _ad70 = _ad70 + 1; end;
if P_RESPOND1 >= .65 then do; if _Ftarget = '1' then _aa65 = _aa65 + 1; else _ab65 = _ab65 + 1; end; else do; if _Ftarget = '1' then _ac65 = _ac65 + 1; else _ad65 = _ad65 + 1; end;
if P_RESPOND1 >= .60 then do; if _Ftarget = '1' then _aa60 = _aa60 + 1; else _ab60 = _ab60 + 1; end; else do; if _Ftarget = '1' then _ac60 = _ac60 + 1; else _ad60 = _ad60 + 1; end;
if P_RESPOND1 >= .55 then do; if _Ftarget = '1' then _aa55 = _aa55 + 1; else _ab55 = _ab55 + 1; end; else do; if _Ftarget = '1' then _ac55 = _ac55 + 1; else _ad55 = _ad55 + 1; end;
if P_RESPOND1 >= .50 then do; if _Ftarget = '1' then _aa50 = _aa50 + 1; else _ab50 = _ab50 + 1; end; else do; if _Ftarget = '1' then _ac50 = _ac50 + 1; else _ad50 = _ad50 + 1; end;
if P_RESPOND1 >= .45 then do; if _Ftarget = '1' then _aa45 = _aa45 + 1; else _ab45 = _ab45 + 1; end; else do; if _Ftarget = '1' then _ac45 = _ac45 + 1; else _ad45 = _ad45 + 1; end;
if P_RESPOND1 >= .40 then do; if _Ftarget = '1' then _aa40 = _aa40 + 1; else _ab40 = _ab40 + 1; end; else do; if _Ftarget = '1' then _ac40 = _ac40 + 1; else _ad40 = _ad40 + 1; end;
if P_RESPOND1 >= .35 then do; if _Ftarget = '1' then _aa35 = _aa35 + 1; else _ab35 = _ab35 + 1; end; else do; if _Ftarget = '1' then _ac35 = _ac35 + 1; else _ad35 = _ad35 + 1; end;
if P_RESPOND1 >= .30 then do; if _Ftarget = '1' then _aa30 = _aa30 + 1; else _ab30 = _ab30 + 1; end; else do; if _Ftarget = '1' then _ac30 = _ac30 + 1; else _ad30 = _ad30 + 1; end;
if P_RESPOND1 >= .25 then do; if _Ftarget = '1' then _aa25 = _aa25 + 1; else _ab25 = _ab25 + 1; end; else do; if _Ftarget = '1' then _ac25 = _ac25 + 1; else _ad25 = _ad25 + 1; end;
if P_RESPOND1 >= .20 then do; if _Ftarget = '1' then _aa20 = _aa20 + 1; else _ab20 = _ab20 + 1; end; else do; if _Ftarget = '1' then _ac20 = _ac20 + 1; else _ad20 = _ad20 + 1; end;
if P_RESPOND1 >= .15 then do; if _Ftarget = '1' then _aa15 = _aa15 + 1; else _ab15 = _ab15 + 1; end; else do; if _Ftarget = '1' then _ac15 = _ac15 + 1; else _ad15 = _ad15 + 1; end;
if P_RESPOND1 >= .10 then do; if _Ftarget = '1' then _aa10 = _aa10 + 1; else _ab10 = _ab10 + 1; end; else do; if _Ftarget = '1' then _ac10 = _ac10 + 1; else _ad10 = _ad10 + 1; end;
if P_RESPOND1 >= .05 then do; if _Ftarget = '1' then _aa05 = _aa05 + 1; else _ab05 = _ab05 + 1; end; else do; if _Ftarget = '1' then _ac05 = _ac05 + 1; else _ad05 = _ad05 + 1; end;
if P_RESPOND1 >= 0 then do; if _Ftarget = '1' then _aa00 = _aa00 + 1; else _ab00 = _ab00 + 1; end; else do; if _Ftarget = '1' then _ac00 = _ac00 + 1; else _ad00 = _ad00 + 1; end; /* process target level 2 */ if P_RESPOND0 = 1 then do; if _Ftarget = '0' then _ba99 = _ba99 + 1; else _bb99 = _bb99 + 1; end; else do; if _Ftarget = '0' then _bc99 = _bc99 + 1; else _bd99 = _bd99 + 1; end;
if P_RESPOND0 >= .95 then do; if _Ftarget = '0' then _ba95 = _ba95 + 1; else _bb95 = _bb95 + 1; end; else do; if _Ftarget = '0' then _bc95 = _bc95 + 1; else _bd95 = _bd95 + 1; end;
if P_RESPOND0 >= .90 then do; if _Ftarget = '0' then _ba90 = _ba90 + 1; else _bb90 = _bb90 + 1; end; else do; if _Ftarget = '0' then _bc90 = _bc90 + 1; else _bd90 = _bd90 + 1; end;
if P_RESPOND0 >= .85 then do; if _Ftarget = '0' then _ba85 = _ba85 + 1; else _bb85 = _bb85 + 1; end; else do; if _Ftarget = '0' then _bc85 = _bc85 + 1; else _bd85 = _bd85 + 1; end;
if P_RESPOND0 >= .80 then do; if _Ftarget = '0' then _ba80 = _ba80 + 1; else _bb80 = _bb80 + 1; end; else do; if _Ftarget = '0' then _bc80 = _bc80 + 1; else _bd80 = _bd80 + 1; end;
if P_RESPOND0 >= .75 then do; if _Ftarget = '0' then _ba75 = _ba75 + 1; else _bb75 = _bb75 + 1; end; else do; if _Ftarget = '0' then _bc75 = _bc75 + 1; else _bd75 = _bd75 + 1; end;
if P_RESPOND0 >= .70 then do; if _Ftarget = '0' then _ba70 = _ba70 + 1; else _bb70 = _bb70 + 1; end; else do; if _Ftarget = '0' then _bc70 = _bc70 + 1; else _bd70 = _bd70 + 1; end;
if P_RESPOND0 >= .65 then do; if _Ftarget = '0' then _ba65 = _ba65 + 1; else _bb65 = _bb65 + 1; end; else do; if _Ftarget = '0' then _bc65 = _bc65 + 1; else _bd65 = _bd65 + 1; end;
if P_RESPOND0 >= .60 then do; if _Ftarget = '0' then _ba60 = _ba60 + 1; else _bb60 = _bb60 + 1; end; else do; if _Ftarget = '0' then _bc60 = _bc60 + 1; else _bd60 = _bd60 + 1; end;
if P_RESPOND0 >= .55 then do; if _Ftarget = '0' then _ba55 = _ba55 + 1; else _bb55 = _bb55 + 1; end; else do; if _Ftarget = '0' then _bc55 = _bc55 + 1; else _bd55 = _bd55 + 1; end;
if P_RESPOND0 >= .50 then do; if _Ftarget = '0' then _ba50 = _ba50 + 1; else _bb50 = _bb50 + 1; end; else do; if _Ftarget = '0' then _bc50 = _bc50 + 1; else _bd50 = _bd50 + 1; end;
if P_RESPOND0 >= .45 then do; if _Ftarget = '0' then _ba45 = _ba45 + 1; else _bb45 = _bb45 + 1; end; else do; if _Ftarget = '0' then _bc45 = _bc45 + 1; else _bd45 = _bd45 + 1; end;
if P_RESPOND0 >= .40 then do; if _Ftarget = '0' then _ba40 = _ba40 + 1; else _bb40 = _bb40 + 1; end; else do; if _Ftarget = '0' then _bc40 = _bc40 + 1; else _bd40 = _bd40 + 1; end;
if P_RESPOND0 >= .35 then do; if _Ftarget = '0' then _ba35 = _ba35 + 1; else _bb35 = _bb35 + 1; end; else do; if _Ftarget = '0' then _bc35 = _bc35 + 1; else _bd35 = _bd35 + 1; end;
if P_RESPOND0 >= .30 then do; if _Ftarget = '0' then _ba30 = _ba30 + 1; else _bb30 = _bb30 + 1; end; else do; if _Ftarget = '0' then _bc30 = _bc30 + 1; else _bd30 = _bd30 + 1; end;
if P_RESPOND0 >= .25 then do; if _Ftarget = '0' then _ba25 = _ba25 + 1; else _bb25 = _bb25 + 1; end; else do; if _Ftarget = '0' then _bc25 = _bc25 + 1; else _bd25 = _bd25 + 1; end;
if P_RESPOND0 >= .20 then do; if _Ftarget = '0' then _ba20 = _ba20 + 1; else _bb20 = _bb20 + 1; end; else do; if _Ftarget = '0' then _bc20 = _bc20 + 1; else _bd20 = _bd20 + 1; end;
if P_RESPOND0 >= .15 then do; if _Ftarget = '0' then _ba15 = _ba15 + 1; else _bb15 = _bb15 + 1; end; else do; if _Ftarget = '0' then _bc15 = _bc15 + 1; else _bd15 = _bd15 + 1; end;
if P_RESPOND0 >= .10 then do; if _Ftarget = '0' then _ba10 = _ba10 + 1; else _bb10 = _bb10 + 1; end; else do; if _Ftarget = '0' then _bc10 = _bc10 + 1; else _bd10 = _bd10 + 1; end;
if P_RESPOND0 >= .05 then do; if _Ftarget = '0' then _ba05 = _ba05 + 1; else _bb05 = _bb05 + 1; end; else do; if _Ftarget = '0' then _bc05 = _bc05 + 1; else _bd05 = _bd05 + 1; end;
if P_RESPOND0 >= 0 then do; if _Ftarget = '0' then _ba00 = _ba00 + 1; else _bb00 = _bb00 + 1; end; else do; if _Ftarget = '0' then _bc00 = _bc00 + 1; else _bd00 = _bd00 + 1; end; if last_obn then do; _thresh=100;_lvlord='A'; _actual='1'; _predict='1'; _freq=_aa99; output; _actual='1'; _predict='0'; _freq=_ac99; output; _actual='0'; _predict='1'; _freq=_ab99; output; _actual='0'; _predict='0'; _freq=_ad99; output;
_thresh=95; _actual='1'; _predict='1'; _freq=_aa95; output; _actual='1'; _predict='0'; _freq=_ac95; output; _actual='0'; _predict='1'; _freq=_ab95; output; _actual='0'; _predict='0'; _freq=_ad95; output;
_thresh=90; _actual='1'; _predict='1'; _freq=_aa90; output; _actual='1'; _predict='0'; _freq=_ac90; output; _actual='0'; _predict='1'; _freq=_ab90; output; _actual='0'; _predict='0'; _freq=_ad90; output;
_thresh=85; _actual='1'; _predict='1'; _freq=_aa85; output; _actual='1'; _predict='0'; _freq=_ac85; output; _actual='0'; _predict='1'; _freq=_ab85; output; _actual='0'; _predict='0'; _freq=_ad85; output;
_thresh=80; _actual='1'; _predict='1'; _freq=_aa80; output; _actual='1'; _predict='0'; _freq=_ac80; output; _actual='0'; _predict='1'; _freq=_ab80; output; _actual='0'; _predict='0'; _freq=_ad80; output;
_thresh=75; _actual='1'; _predict='1'; _freq=_aa75; output; _actual='1'; _predict='0'; _freq=_ac75; output; _actual='0'; _predict='1'; _freq=_ab75; output; _actual='0'; _predict='0'; _freq=_ad75; output;
_thresh=70; _actual='1'; _predict='1'; _freq=_aa70; output; _actual='1'; _predict='0'; _freq=_ac70; output; _actual='0'; _predict='1'; _freq=_ab70; output; _actual='0'; _predict='0'; _freq=_ad70; output;
_thresh=65; _actual='1'; _predict='1'; _freq=_aa65; output; _actual='1'; _predict='0'; _freq=_ac65; output; _actual='0'; _predict='1'; _freq=_ab65; output; _actual='0'; _predict='0'; _freq=_ad65; output;
_thresh=60; _actual='1'; _predict='1'; _freq=_aa60; output; _actual='1'; _predict='0'; _freq=_ac60; output; _actual='0'; _predict='1'; _freq=_ab60; output; _actual='0'; _predict='0'; _freq=_ad60; output;
_thresh=55; _actual='1'; _predict='1'; _freq=_aa55; output; _actual='1'; _predict='0'; _freq=_ac55; output; _actual='0'; _predict='1'; _freq=_ab55; output; _actual='0'; _predict='0'; _freq=_ad55; output;
_thresh=50; _actual='1'; _predict='1'; _freq=_aa50; output; _actual='1'; _predict='0'; _freq=_ac50; output; _actual='0'; _predict='1'; _freq=_ab50; output; _actual='0'; _predict='0'; _freq=_ad50; output;
_thresh=45; _actual='1'; _predict='1'; _freq=_aa45; output; _actual='1'; _predict='0'; _freq=_ac45; output; _actual='0'; _predict='1'; _freq=_ab45; output; _actual='0'; _predict='0'; _freq=_ad45; output;
_thresh=40; _actual='1'; _predict='1'; _freq=_aa40; output; _actual='1'; _predict='0'; _freq=_ac40; output; _actual='0'; _predict='1'; _freq=_ab40; output; _actual='0'; _predict='0'; _freq=_ad40; output;
_thresh=35; _actual='1'; _predict='1'; _freq=_aa35; output; _actual='1'; _predict='0'; _freq=_ac35; output; _actual='0'; _predict='1'; _freq=_ab35; output; _actual='0'; _predict='0'; _freq=_ad35; output;
_thresh=30; _actual='1'; _predict='1'; _freq=_aa30; output; _actual='1'; _predict='0'; _freq=_ac30; output; _actual='0'; _predict='1'; _freq=_ab30; output; _actual='0'; _predict='0'; _freq=_ad30; output;
_thresh=25; _actual='1'; _predict='1'; _freq=_aa25; output; _actual='1'; _predict='0'; _freq=_ac25; output; _actual='0'; _predict='1'; _freq=_ab25; output; _actual='0'; _predict='0'; _freq=_ad25; output;
_thresh=20; _actual='1'; _predict='1'; _freq=_aa20; output; _actual='1'; _predict='0'; _freq=_ac20; output; _actual='0'; _predict='1'; _freq=_ab20; output; _actual='0'; _predict='0'; _freq=_ad20; output;
_thresh=15; _actual='1'; _predict='1'; _freq=_aa15; output; _actual='1'; _predict='0'; _freq=_ac15; output; _actual='0'; _predict='1'; _freq=_ab15; output; _actual='0'; _predict='0'; _freq=_ad15; output;
_thresh=10; _actual='1'; _predict='1'; _freq=_aa10; output; _actual='1'; _predict='0'; _freq=_ac10; output; _actual='0'; _predict='1'; _freq=_ab10; output; _actual='0'; _predict='0'; _freq=_ad10; output;
_thresh= 5; _actual='1'; _predict='1'; _freq=_aa05; output; _actual='1'; _predict='0'; _freq=_ac05; output; _actual='0'; _predict='1'; _freq=_ab05; output; _actual='0'; _predict='0'; _freq=_ad05; output;
_thresh= 0; _actual='1'; _predict='1'; _freq=_aa00; output; _actual='1'; _predict='0'; _freq=_ac00; output; _actual='0'; _predict='1'; _freq=_ab00; output; _actual='0'; _predict='0'; _freq=_ad00; output; _thresh=100;_lvlord='B'; _actual='1'; _predict='1'; _freq=_bd99; output; _actual='1'; _predict='0'; _freq=_bb99; output; _actual='0'; _predict='1'; _freq=_bc99; output; _actual='0'; _predict='0'; _freq=_ba99; output;
_thresh=95; _actual='1'; _predict='1'; _freq=_bd95; output; _actual='1'; _predict='0'; _freq=_bb95; output; _actual='0'; _predict='1'; _freq=_bc95; output; _actual='0'; _predict='0'; _freq=_ba95; output;
_thresh=90; _actual='1'; _predict='1'; _freq=_bd90; output; _actual='1'; _predict='0'; _freq=_bb90; output; _actual='0'; _predict='1'; _freq=_bc90; output; _actual='0'; _predict='0'; _freq=_ba90; output;
_thresh=85; _actual='1'; _predict='1'; _freq=_bd85; output; _actual='1'; _predict='0'; _freq=_bb85; output; _actual='0'; _predict='1'; _freq=_bc85; output; _actual='0'; _predict='0'; _freq=_ba85; output;
_thresh=80; _actual='1'; _predict='1'; _freq=_bd80; output; _actual='1'; _predict='0'; _freq=_bb80; output; _actual='0'; _predict='1'; _freq=_bc80; output; _actual='0'; _predict='0'; _freq=_ba80; output;
_thresh=75; _actual='1'; _predict='1'; _freq=_bd75; output; _actual='1'; _predict='0'; _freq=_bb75; output; _actual='0'; _predict='1'; _freq=_bc75; output; _actual='0'; _predict='0'; _freq=_ba75; output;
_thresh=70; _actual='1'; _predict='1'; _freq=_bd70; output; _actual='1'; _predict='0'; _freq=_bb70; output; _actual='0'; _predict='1'; _freq=_bc70; output; _actual='0'; _predict='0'; _freq=_ba70; output;
_thresh=65; _actual='1'; _predict='1'; _freq=_bd65; output; _actual='1'; _predict='0'; _freq=_bb65; output; _actual='0'; _predict='1'; _freq=_bc65; output; _actual='0'; _predict='0'; _freq=_ba65; output;
_thresh=60; _actual='1'; _predict='1'; _freq=_bd60; output; _actual='1'; _predict='0'; _freq=_bb60; output; _actual='0'; _predict='1'; _freq=_bc60; output; _actual='0'; _predict='0'; _freq=_ba60; output;
_thresh=55; _actual='1'; _predict='1'; _freq=_bd55; output; _actual='1'; _predict='0'; _freq=_bb55; output; _actual='0'; _predict='1'; _freq=_bc55; output; _actual='0'; _predict='0'; _freq=_ba55; output;
_thresh=50; _actual='1'; _predict='1'; _freq=_bd50; output; _actual='1'; _predict='0'; _freq=_bb50; output; _actual='0'; _predict='1'; _freq=_bc50; output; _actual='0'; _predict='0'; _freq=_ba50; output;
_thresh=45; _actual='1'; _predict='1'; _freq=_bd45; output; _actual='1'; _predict='0'; _freq=_bb45; output; _actual='0'; _predict='1'; _freq=_bc45; output; _actual='0'; _predict='0'; _freq=_ba45; output;
_thresh=40; _actual='1'; _predict='1'; _freq=_bd40; output; _actual='1'; _predict='0'; _freq=_bb40; output; _actual='0'; _predict='1'; _freq=_bc40; output; _actual='0'; _predict='0'; _freq=_ba40; output;
_thresh=35; _actual='1'; _predict='1'; _freq=_bd35; output; _actual='1'; _predict='0'; _freq=_bb35; output; _actual='0'; _predict='1'; _freq=_bc35; output; _actual='0'; _predict='0'; _freq=_ba35; output;
_thresh=30; _actual='1'; _predict='1'; _freq=_bd30; output; _actual='1'; _predict='0'; _freq=_bb30; output; _actual='0'; _predict='1'; _freq=_bc30; output; _actual='0'; _predict='0'; _freq=_ba30; output;
_thresh=25; _actual='1'; _predict='1'; _freq=_bd25; output; _actual='1'; _predict='0'; _freq=_bb25; output; _actual='0'; _predict='1'; _freq=_bc25; output; _actual='0'; _predict='0'; _freq=_ba25; output;
_thresh=20; _actual='1'; _predict='1'; _freq=_bd20; output; _actual='1'; _predict='0'; _freq=_bb20; output; _actual='0'; _predict='1'; _freq=_bc20; output; _actual='0'; _predict='0'; _freq=_ba20; output;
_thresh=15; _actual='1'; _predict='1'; _freq=_bd15; output; _actual='1'; _predict='0'; _freq=_bb15; output; _actual='0'; _predict='1'; _freq=_bc15; output; _actual='0'; _predict='0'; _freq=_ba15; output;
_thresh=10; _actual='1'; _predict='1'; _freq=_bd10; output; _actual='1'; _predict='0'; _freq=_bb10; output; _actual='0'; _predict='1'; _freq=_bc10; output; _actual='0'; _predict='0'; _freq=_ba10; output;
_thresh= 5; _actual='1'; _predict='1'; _freq=_bd05; output; _actual='1'; _predict='0'; _freq=_bb05; output; _actual='0'; _predict='1'; _freq=_bc05; output; _actual='0'; _predict='0'; _freq=_ba05; output;
_thresh= 0; _actual='1'; _predict='1'; _freq=_bd00; output; _actual='1'; _predict='0'; _freq=_bb00; output; _actual='0'; _predict='1'; _freq=_bc00; output; _actual='0'; _predict='0'; _freq=_ba00; output; end; run;
*********************************************************************; *********************************************************************; ***************** USER DEFIENED MODEL 끝 **************************; *********************************************************************; *********************************************************************;
* Assessment(평가) 노드;
* _respc (_resp) : %Response; * _capc (_cap) : %Captured Response; * _liftc (_lift) : LIFT VALUE; * _profitc(_profit): PROFIT;
data work.tmplift(rename=(_tool_=tool _decile=decile)); length _tool_ $10 modelid $8 modelnm $8 modelnam $20; set EMPROJ._A00005R EMPROJ._A00005O EMPROJ._A00002V EMPROJ._A000002 EMPROJ._A00005S; modelnm = modelnam; run;
data tmplift; set tmplift; length decile2 $4 uptool $20 toolname $12; drop tmpdm tmpne tmptr tmpre tmpuser tmpelse uptool len; retain tmpdm 0 tmpne 0 tmptr 0 tmpre 0 tmpuser 0 tmpelse 0 rounded; if _n_ = 1 then do; if decile in(1,2,5,10,20,25,50) then rounded = 'Y'; else rounded = 'N'; end; if rounded = 'Y' then decile2 = left(putn(decile,3.)); else decile2 = left(putn(decile,4.1)); uptool = upcase(tool); if uptool =: 'DMINE' then tool = 'DMine'; else if uptool =: 'NEURAL' then tool = 'Neural'; else if (uptool =: 'DATA' or uptool =: 'DATASPLT' or uptool =: 'SPLT') then tool = 'Tree'; else if uptool =: 'REG' then tool = 'Reg'; else if uptool =: 'USER' then tool = 'User'; else if uptool ^= 'EXACT' and uptool ^= 'BASELINE' then do; toolname = tool; tool = substr(tool,1,6); end; if toolname = '' then toolname = tool; if tool = 'DMine' then do; tmpdm + 1; if tmpdm > 10 then tool = trim(tool) || '-' || left(putn(int((tmpdm-1)/10)+1,2.)); end; else if tool = 'Neural' then do; tmpne + 1; if tmpne > 10 then tool = trim(tool) || '-' || left(putn(int((tmpne-1)/10)+1,2.)); end; else if tool = 'Tree' then do; tmptr + 1; if tmptr > 10 then tool = trim(tool) || '-' || left(putn(int((tmptr-1)/10)+1,2.)); end; else if tool = 'Reg' then do; tmpre + 1; if tmpre > 10 then tool = trim(tool) || '-' || left(putn(int((tmpre-1)/10)+1,2.)); end; else if tool = 'User' then do; tmpuser + 1; if tmpuser > 10 then tool = trim(tool) || '-' || left(putn(int((tmpuser-1)/10)+1,2.)); end; else if uptool ^= 'EXACT' and uptool ^= 'BASELINE' then do; tmpelse + 1; if tmpelse > 10 then tool = trim(tool) || '-' || left(putn(int((tmpelse-1)/10)+1,2.)); end; run;
data _liftdat; set tmplift; drop decile2 _iscost0 modelnam; modelnm = modelnam; Label toolname = 'Modeling Tool' tool = 'Modeling Tool' modelid = 'Model ID' modelnm = 'Model Name' _eprofit = 'Expected Profit at Cutoff' _profit = 'Average Profit Per Observation' _profitc = 'Cumulative Profit Per Observation' _resp = 'Response Rate (%)' _cap = 'Captured Response Rate (%)' _lift = 'Lift Value' _roi = 'Return on Investment' _respc = 'Cumulative Response Rate (%)' _capc = 'Cumulative Captured Response Rate (%)' _liftc = 'Cumulative Lift Value' _roic = 'Cumulative Return on Investment' _gcount = 'Number of Observations in each Group' decile = 'Percentile' _cutoff = 'Posterior Probability Cutoff (Event)'; Format _resp 7.3 _cap 7.3 _lift 9.3 _respc 7.3 _capc 7.3 _liftc 9.3 _cutoff 7.3 _gcount 15.2 _roi 12.5 _roic 12.5; run;
/* proc sort data=Tmplift; by tool decile; run; */ |
|
2007년 백승민 제작하였답니다. (http://cafe.daum.net/statsas , http://statwith.pe.kr) |
|