SAS Code for Preliminary Results
January 11, 2013
libname nypd "g:\nypd";
options linesize=130;
proc contents data=nypd.stop2007; run;
proc contents data=nypd.stop2008; run;
proc contents data=nypd.stop2009; run;
proc contents data=nypd.stop2010; run;
*************************************;
*Data cleaning procedures to reconcile mismatches;
*between character and numeric variables and other;
*technical inconsistencies across years. NYPD;
*documentation specifies that variable coding is consistent;
*for 2006 to 2010 -- making it impossible to match with 2003;
*2004 and 2005 data. 2006 data, however, have more than a dozen additional;
*inconsistencies beyond those corrected in the code below. Therefore, we will confine our database to;
*stop-and-frisk activities from 2007 to 2010 inclusive;
data nypd.new2007 (compress=yes);
set nypd.stop2007;
length x_stname $ 32;
x_stname=stname;
x_htft=0; x_htft=ht_feet;
x_htin=0; x_htin=ht_inch;
x_beat=0; x_beat=beat;
x_post=0; x_post=post;
x_pct=0; xpct=pct;
x_timest=0; x_timest=timestop;
x_datest=0; x_datest=datestop;
x_repcmd=0; x_repcmd=repcmd;
x_revcmd=0; x_revcmd=revcmd;
x_addpct=0; x_addpct=addrpct;
length x_xcoord 7 x_ycoord 7;
x_xcoord=0; x_xcoord=xcoord;
x_ycoord=0; x_ycoord=ycoord;
drop pct timestop repcmd revcmd addrpct xcoord ycoord ht_feet ht_inch beat post datestop stname;
run;
data nypd.new2008 (compress=yes);
set nypd.stop2008;
length x_stname $ 32;
x_stname=stname;
x_htft=0; x_htft=ht_feet;
x_htin=0; x_htin=ht_inch;
x_beat=0; x_beat=beat;
x_post=0; x_post=post;
x_pct=0; xpct=pct;
x_timest=0; x_timest=timestop;
x_datest=0; x_datest=datestop;
x_repcmd=0; x_repcmd=repcmd;
x_revcmd=0; x_revcmd=revcmd;
x_addpct=0; x_addpct=addrpct;
length x_xcoord 7 x_ycoord 7;
x_xcoord=0; x_xcoord=xcoord;
x_ycoord=0; x_ycoord=ycoord;
drop pct timestop repcmd revcmd addrpct xcoord ycoord ht_feet ht_inch beat post datestop stname;
run;
data nypd.new2009 (compress=yes);
set nypd.stop2009;
length x_stname $ 32;
x_stname=stname;
x_htft=0; x_htft=ht_feet;
x_htin=0; x_htin=ht_inch;
x_beat=0; x_beat=beat;
x_post=0; x_post=post;
x_pct=0; xpct=pct;
x_timest=0; x_timest=timestop;
x_datest=0; x_datest=datestop;
x_repcmd=0; x_repcmd=repcmd;
x_revcmd=0; x_revcmd=revcmd;
x_addpct=0; x_addpct=addrpct;
length x_xcoord 7 x_ycoord 7;
x_xcoord=0; x_xcoord=xcoord;
x_ycoord=0; x_ycoord=ycoord;
drop pct timestop repcmd revcmd addrpct xcoord ycoord ht_feet ht_inch beat post datestop stname;
run;
data nypd.new2010 (compress=yes);
set nypd.stop2010;
length x_stname $ 32;
x_stname=stname;
x_htft=0; x_htft=ht_feet;
x_htin=0; x_htin=ht_inch;
x_beat=0; x_beat=beat;
x_post=0; x_post=post;
x_pct=pct;
x_timest=timestop;
x_datest=0; x_datest=datestop;
x_repcmd=repcmd;
x_revcmd=revcmd;
x_addpct=addrpct;
length x_xcoord 7 x_ycoord 7;
x_xcoord=xcoord;
x_ycoord=ycoord;
drop pct timestop repcmd revcmd addrpct xcoord ycoord ht_feet ht_inch beat post datestop stname;
run;
data nypd.master(compress=yes);
set
nypd.new2007
nypd.new2008
nypd.new2009
nypd.new2010;
run;
proc contents data=nypd.master; run;
proc freq data=nypd.master;
tables race*frisked
race*searched
race*arstmade;
run;
proc freq data=nypd.master;
tables race;
where (arstmade="Y") and (pistol="Y" or riflshot="Y" or asltweap="Y" or machgun="Y");
run;