*****************************************; ** SAS Scoring Code for PROC Logistic; *****************************************; length I_top10 $ 12; label I_top10 = 'Into: top10' ; label U_top10 = 'Unnormalized Into: top10' ; label P_top101 = 'Predicted: top10=1' ; label P_top100 = 'Predicted: top10=0' ; drop _LMR_BAD; _LMR_BAD=0; * LABEL STATEMENTS TO DESCRIBE PREDICTORS; label prob_days_100 ='100+ days of probation this or last year' adj_react ='Adjustment reaction ICD-9 309 this or last year' chron_r ='Diagnosed with chronic medical condition' cjic_arr ='Arrested this or last year' cjic_arr_1 ='Number of arrests this year' cjic_arr_SEC_1='Jail security level=3 or 4 in current year' cjic_arr_bk_1 ='Booking code 849A or 849B in current year' cjic_cite ='Jail booking this or last year' cjic_days_1 ='Number of days in jail this year' cta_chr_hmls ='HMIS chronic homeless flag' ems_1 ='Emergency Medical service record this year' ems_2 ='Emergency Medical service record last year' ems_gt2 ='Number of EMS encounters > 2 this or last year' icd_HC ='Diagnosis of high-cost ICD-9 this or last year' fs_gt1 ='More than 1 month in food stamp payment this or last year' heart ='Diagnosis of heart disease ICD-9 402-429 this or last year' inp_c_1 ='Number of inpatient admissions this year' inp_days ='Total # of inpatient days this & last year' inp_em ='Inpatient via ER or from psych. fac. this or last year' mh_outp_d ='Number of MH outpatient days this & last year' mh_outp_gt1 ='Mental Health outpatient visits > 1 last 2 years' mh_inp_c_1 ='Number of Mental Health inpatient admissions this year' organs_cnt ='Count of ICD-9 (Organ Failures) 569-573, 576-578, 585-594, or 596 this & last year' oth_mort ='other ill-defined/unknown causes of morbidity and mortality with ICD-9 799 this or last year' outp_1 ='VMC non-inpatient health system encounters this year' outp_c_1 ='Number of non-inpatient health system encounterss this year' outp_em_1 ='if outpatient ER, psych serv or amb.surgery - current year' outp_gt10_1 ='Non-inpatient health system encounterss this year > 10' schiz ='Diagnosis of schizophrenia ICD-9 295 this or last year' ssa_1 ='Public assistance benefits in current year' Sub_Abuse ='Substance abuse indicated by medical diagnosis or justice system charge' dads_cnt ='Total # of DADS encounters this & last year' mh_inp_gt1_1 ='Mental Health inpatient admissions > 1 this or last year' neoplas_cnt ='Count of diagnosis of neoplasm (ICD-9 140-239) this & last year' ; *** Check interval variables for missing values; if nmiss(prob_days_100,adj_react,chron_r,cjic_arr,cjic_arr_1,cjic_arr_SEC_1, cjic_arr_bk_1,cjic_cite,cjic_days_1,cta_chr_hmls,ems_1,ems_2,ems_gt2, icd_HC,fs_gt1,heart,inp_c_1,inp_days,inp_em,mh_outp_d,mh_outp_gt1, mh_inp_c_1,organs_cnt,oth_mort,outp_1,outp_c_1,outp_em_1,outp_gt10_1, schiz,ssa_1,Sub_Abuse,dads_cnt,mh_inp_gt1_1,neoplas_cnt) then do; _LMR_BAD=1; goto _SKIP_000; end; *** Generate design variables for sex; drop _0_0 ; length _st1 $ 1; drop _st1; _st1 = left(trim(put (sex, $1.))); _0_0= 0; if _st1 = 'F' then do; _0_0 = 1; end; else if _st1 = 'M' then do; _0_0= -1; end; else do; _0_0 = .; _LMR_BAD=1; goto _SKIP_000; end; *** Generate design variables for age_gr; drop _1_0 _1_1 _1_2 ; length _st9 $ 9; drop _st9; _st9 = left(trim(put (age_gr, $9.))); _1_0= 0; _1_1= 0; _1_2= 0; if _st9 = '18-45' then do; _1_0 = 1; end; else if _st9 = '46-65' then do; _1_1 = 1; end; else if _st9 = '65+' then do; _1_2 = 1; end; else if _st9 = 'lt-18' then do; _1_0= -1; _1_1= -1; _1_2= -1; end; else do; _1_0 = .; _1_1 = .; _1_2 = .; _LMR_BAD=1; goto _SKIP_000; end; *** Compute Linear Predictors; drop _LP0; _LP0 = 0; *** Effect: age_gr; _TEMP = 1; _LP0 = _LP0 + (0.34059495520084) * _TEMP * _1_0; _LP0 = _LP0 + (0.13968494844892) * _TEMP * _1_1; _LP0 = _LP0 + (0.11614431391268) * _TEMP * _1_2; *** Effect: sex; _TEMP = 1; _LP0 = _LP0 + (0.04411146937694) * _TEMP * _0_0; _LP0 = _LP0 + (0.18484873388559) * prob_days_100; _LP0 = _LP0 + (0.13609975612453) * adj_react; _LP0 = _LP0 + (0.04895489134286) * chron_r; _LP0 = _LP0 + (0.44197817895601) * cjic_arr; _LP0 = _LP0 + (0.20954675975009) * cjic_arr_1; _LP0 = _LP0 + (0.43934935918945) * cjic_arr_SEC_1; _LP0 = _LP0 + (0.64042215407843) * cjic_arr_bk_1; _LP0 = _LP0 + (0.1223452276631) * cjic_cite; _LP0 = _LP0 + (0.00718644662783) * cjic_days_1; _LP0 = _LP0 + (0.28192769237099) * cta_chr_hmls; _LP0 = _LP0 + (0.14118749801468) * ems_1; _LP0 = _LP0 + (0.23787129999965) * ems_2; _LP0 = _LP0 + (0.26092985606152) * ems_gt2; _LP0 = _LP0 + (0.08995915450506) * icd_HC; _LP0 = _LP0 + (-0.36301570180134) * fs_gt1; _LP0 = _LP0 + (0.43527492340347) * heart; _LP0 = _LP0 + (0.13817180102488) * inp_c_1; _LP0 = _LP0 + (0.01224402559881) * inp_days; _LP0 = _LP0 + (0.39288101039943) * inp_em; _LP0 = _LP0 + (0.01064304679293) * mh_outp_d; _LP0 = _LP0 + (0.3695261529729) * mh_outp_gt1; _LP0 = _LP0 + (0.00274229911225) * mh_inp_c_1; _LP0 = _LP0 + (0.0791883039101) * organs_cnt; _LP0 = _LP0 + (0.11354946277033) * oth_mort; _LP0 = _LP0 + (0.20908987688703) * outp_1; _LP0 = _LP0 + (0.02395296933262) * outp_c_1; _LP0 = _LP0 + (0.02342904649225) * outp_em_1; _LP0 = _LP0 + (0.23901190368433) * outp_gt10_1; _LP0 = _LP0 + (0.37949788208024) * schiz; _LP0 = _LP0 + (0.29913637684586) * ssa_1; _LP0 = _LP0 + (0.47455302603067) * Sub_Abuse; _LP0 = _LP0 + (0.00213648221448) * dads_cnt; _LP0 = _LP0 + (0.39265637130671) * mh_inp_gt1_1; _LP0 = _LP0 + (0.05005306320528) * neoplas_cnt; *** Effect: mh_outp_gt10*age_gr; _TEMP = mh_outp_gt10; _LP0 = _LP0 + (-0.17700846963535) * _TEMP * _1_0; _LP0 = _LP0 + (-0.22611857103319) * _TEMP * _1_1; _LP0 = _LP0 + (-1.3812527522529) * _TEMP * _1_2; _LP0 = _LP0 + (-0.84303105007885) * heart * mh_outp_gt1; _LP0 = _LP0 + (-0.39378196335407) * inp_em * mh_inp_gt1_1; _LP0 = _LP0 + (-0.0008838015018) * cjic_arr_1 * cjic_days_1; _LP0 = _LP0 + (-0.39309066580315) * adj_react * cta_chr_hmls; _LP0 = _LP0 + (0.23496365450024) * chron_r * ems_1; _LP0 = _LP0 + (0.26671621212913) * chron_r * outp_em_1; _LP0 = _LP0 + (-0.5514524972113) * cjic_arr_bk_1 * ems_1; _LP0 = _LP0 + (-0.30705085640449) * prob_days_100 * cjic_arr_bk_1; *** Predicted values; drop _MAXP _IY _P0 _P1; _TEMP = -3.81182860403159 + _LP0; if (_TEMP < 0) then do; _TEMP = exp(_TEMP); _P0 = _TEMP / (1 + _TEMP); end; else _P0 = 1 / (1 + exp(-_TEMP)); _P1 = 1.0 - _P0; P_top101 = _P0; _MAXP = _P0; _IY = 1; P_top100 = _P1; if (_P1 > _MAXP + 1E-8) then do; _MAXP = _P1; _IY = 2; end; select( _IY ); when (1) do; I_top10 = '1' ; U_top10 = 1; end; when (2) do; I_top10 = '0' ; U_top10 = 0; end; otherwise do; I_top10 = ''; U_top10 = .; end; end; _SKIP_000: if _LMR_BAD = 1 then do; I_top10 = ''; U_top10 = .; P_top101 = .; P_top100 = .; end; drop _TEMP;