Create a gist now

Instantly share code, notes, and snippets.

SAS code used for MODA project to preemptively identify at-risk buildings provided by Sohaib Hasan (http://blog.datalook.io/using-data-analytics-to-make-bad-buildings-better-in-new-york-city/)
*****PCA*****;
proc factor data=foreclosures (drop=n_dep_prty_NURSINGHOME n_dob_app_0001544 n_dob_app_0002571 n_dob_app_0037664 n_dob_app_0007320 n_dob_app_0002920) method=p priors=max rotate=promax mineigen=1.3 outstat=fact1 scree corr res score ultraheywood noprint;
var high_risk_neighborhood aep bip_score erp_charge lien_amount lis_pendens n_311: n_911: n_dep: n_dob: n_ecb: n_fires n_hpd: n_units nm_val_ttl_amt numfloors rent_stab tax_lien yearbuilt;
run;
*****Foreclosures Model*****;
proc logistic data=scores1 descending /*plots=all*/ outest=estimates;
model foreclosure = Factor1 Factor3 Factor4 Factor5 Factor6 Factor9 Factor14 Factor15 Factor18 Factor23 Factor25;
output out=foreclosures_modeled_logit predicted=p_foreclosure u=p_forc_ucl l=p_forc_lcl;
run;
*****B/C Violations Model*****;
proc qlim data=scores4 outest=hpd_bc_truncout;
model hpd_BC_per_unit = factor1 factor2 factor3 factor4 factor5 factor6 factor7 factor8 factor9 factor11 factor12 factor13 factor14 factor16
factor17 factor19 factor21 factor22 factor23 factor24 factor25 factor27;
endogenous hpd_bc_per_unit ~ censored (lb=0);
output out=BCVios_modeled_tobit predicted conditional;
run;
*****DOB Vacates Model*****
proc genmod data=scores6 /*plots=all*/;
model dobvac = factor1 factor2 factor3 factor4 factor5 factor6 factor7 factor8 factor9 factor10 factor11 factor12 factor13 factor14 factor15 factor16
factor17 factor18 factor19 factor20 factor21 factor23 factor24 factor25 factor26 factor27 factor28 / type3 dist=poisson dscale;
output out=dobvac_modeled_pois pred=p_dobvac l=p_dobvac_lcl u=p_dobvac_ucl;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment