*** This syntax is used to aggregate the imported group A data into an *** incident level file and also segment the data into separate files for offenses, *** property, victims, offenders, and arrestees. Recodes for the AGE variables are *** also included here. Run on the file saved at the end of WVIBRSimport. sort cases by ori incnumb level. **************************************. **recodes the victim age and includes an estimate for those cases where an age range was entered. ***************************************. recode dage ('BB' = .7),('NN' = .1),('NB' = .2)(convert) into v_age. missing values v_age(). do if (v_age gt 100). compute begage = trunc(v_age/100). compute endage = mod(v_age,100). end if. do if (v_age ge 100). compute estv_age = rnd(mean(begage,endage)). compute age_chk = 0. if (((endage-begage) gt estv_age) or (estv_age le 0))age_chk = 1. end if. freq age_chk. do if (age_chk = 1). recode estv_age (lo thru hi = sysmis). end if. desc estv_age v_age. if (sysmis(estv_age) and (v_age gt 0 and v_age lt 100)) estv_age = v_age. var lab estv_age 'Includes actual age where approp and an estimate for ages with a range'. missing values v_age (0,100 thru 9999). desc estv_age v_age. do if (estv_age gt 0 and estv_age le 95). compute vage65 = 0. compute vage1017 = 0. compute vage1524 = 0. compute vlt18 = 0. compute vadult = 0. compute vmale = 0. compute vfemale = 0. if (estv_age ge 65)vage65 = 1. if (estv_age ge 10 and estv_age le 17)vage1017 = 1. if (estv_age ge 15 and estv_age le 24)vage1524 = 1. if (estv_age ge 18 and estv_age le 95)vadult = 1. if (estv_age lt 18)vlt18 = 1. if (dsex = 'M')vmale = 1. if (dsex = 'F')vfemale = 1. end if. ********************************************************************* * the following syntax can be used to compute an estimated age for those * OFFENDER (LVL5) records that have a range listed for the age. ***********************************************************************. recode eage ('BB' = .7),('NN' = .1),('NB' = .2)(convert) into o_age. missing values o_age (). do if (o_age ge 100). compute begage = trunc(o_age/100). compute endage = mod(o_age,100). end if. compute esto_age = rnd(mean(begage,endage)). compute age_chk = 0. if (((endage-begage) gt esto_age) or (esto_age le 0))age_chk = 1. do if (age_chk = 1). recode esto_age (lo thru hi = sysmis). end if. desc esto_age o_age. if (sysmis(esto_age) and (o_age gt 0 and o_age lt 100)) esto_age = o_age. var lab esto_age 'includes actual offender age and an estimate for ages with a range'. missing values o_age (0,100 thru 9999). desc esto_age o_age. do if (esto_age ge 5 and esto_age le 99). compute off1017 = 0. compute off1524 = 0. compute o_m_1524 = 0. compute offadult = 0. compute off65 = 0. compute offmale = 0. compute offemale = 0. if (esto_age ge 10 and esto_age le 17)off1017 = 1. if ((esex = 'M') and (esto_age ge 15 and esto_age le 24))o_m_1524 = 1. if (esto_age ge 15 and esto_age le 24)off1524 = 1. if (esto_age ge 18 and esto_age le 95)offadult = 1. if (esto_age ge 65 and esto_age le 95)off65 = 1. if (esex = 'M')offmale = 1. if (esex = 'F')offemale = 1. end if. ********************************************************************* * the following syntax can be used to compute an estimated age for those * arrestee records that have a range listed for the age. ***********************************************************************. recode fage ('BB' = .7),('NN' = .1),('NB' = .2)(convert) into a_age. missing values a_age (). do if (a_age ge 100). compute begage = trunc(a_age/100). compute endage = mod(a_age,100). end if. compute esta_age = rnd(mean(begage,endage)). compute age_chk = 0. if (((endage-begage) gt esta_age) or esta_age le 0)age_chk = 1. do if (age_chk = 1). recode esta_age (lo thru hi = sysmis). end if. desc esta_age a_age. if (sysmis(esta_age) and (a_age gt 0 and a_age lt 100)) esta_age = a_age. var lab esta_age 'includes actual arrestee age and an estimate for ages with a range'. missing values a_age (0,100 thru 9999). desc esta_age a_age. do if (esta_age ge 5 and esta_age le 99). compute arr65 = 0. compute arr1017 = 0. compute arr1524 = 0. compute arradult = 0. compute arrm1524 = 0. compute arr0509 = 0. compute arrmale = 0. compute arfemale = 0. if (esta_age ge 65 and esta_age le 99)arr65 = 1. if (esta_age ge 10 and esta_age le 17)arr1017 = 1. if (esta_age ge 15 and esta_age lt 25)arr1524 = 1. if (esta_age ge 18 and esta_age le 99)arradult = 1. if (esta_age ge 5 and esta_age le 9)arr0509 = 1. if (fsex = 'M')arrmale = 1. if (fsex = 'F')arfemale = 1. end if. compute indivl = 0. if (dvcttype = 'I' or dvcttype = "A" or dvcttype = "J")indivl = 1. *********************************************************************************** * The next section recodes the string offense variables to numeric in both * the offense and arrest segments. ***********************************************************************************. recode foffcode bucrcode ('200' = 200) ('13A' = 130) ('13B' = 171) ('13C' = 172) ('510' = 510) ('220' = 140) ('250' = 250) ('290' = 290) ('35A' = 350) ('35B' = 351) ('270' = 270) ('210' = 210) ('26A' = 260) ('26B' = 261) ('26C' = 262) ('26D' = 263) ('26E' = 264) ('39A' = 390) ('39B' = 391) ('39C' = 392) ('39D' = 393) ('09A' = 90) ('09B' = 198) ('09C' = 199) ('100' = 190) ('23A' = 160) ('23B' = 161) ('23C' = 162) ('23D' = 163) ('23E' = 164) ('23F' = 165) ('23G' = 166) ('23H' = 167) ('240' = 150) ('370' = 370) ('40A' = 400) ('40B' = 401) ('120' = 120) ('11A' = 110) ('11B' = 180) ('11C' = 181) ('11D' = 182) ('36A' = 360) ('36B' = 361) ('280' = 280) ('520' = 520) ('90A' = 901) ('90B' = 902) ('90C' = 903) ('90D' = 904) ('90E' = 905) ('90F' = 906) ('90G' = 907) ('90H' = 908) ('90I' = 909) ('90J' = 910) ('90Z' = 999) into arroff offense. value labels arroff offense 200 'Arson' 130 'Aggravated Assault' 171 'Simple Assault' 172 'Intimidation' 510 'Bribery' 140 'Burglary/Breaking and Entering' 250 'Counterfeiting/Forgery' 290 'Destruction/Damage/Vandalism of Property' 350 'Drug/Narcotics Violations' 351 'Drug Equipment Violations' 270 'Embezzlement' 210 'Extortion/Blackmail' 260 'False Pretenses/Swindle/Confidence Game' 261 'Credit Card/Automated Teller Machine Fraud' 262 'Impersonation' 263 'Welfare Fraud' 264 'Wire Fraud' 390 'Betting/Wagering' 391 'Operating/Promoting/Assisting Gambling' 392 'Gambling Equipment Violations' 393 'Sports Tampering' 90 'Murder and Nonnegligent Manslaughter' 198 'Negligent Manslaughter' 199 'Justifiable Homicide' 190 'Kidnaping/Abduction' 160 'Pocket-picking' 161 'Purse-snatching' 162 'Shoplifting' 163 'Theft From Building' 164 'Theft From Coin-Operated Machine or Device' 165 'Theft From Motor Vehicle' 166 'Theft of Motor Vehicle Parts or Accessories' 167 'All Other Larceny' 150 'Motor Vehicle Theft' 370 'Pornography/Obscene Material' 400 'Prostitution' 401 'Assisting or Promoting Prostitution' 120 'Robbery' 110 'Forcible Rape' 180 'Forcible Sodomy' 181 'Sexual Assault With An Object' 182 'Forcible Fondling' 183 'Rape of a Male' 360 'Incest' 361 'Statutory Rape' 280 'Stolen Property Offenses' 520 'Weapon Law Violations' 901 'Bad Checks' 902 'Curfew/Loitering/Vagrancy' 903 'Disorderly Conduct' 904 'DUI' 905 'Drunkenness' 906 'Nonviolent Family Offenses' 907 'Liquor Law' 908 'Peeping Tom' 909 'Runaway' 910 'Trespass Real Prop' 999 'All Other Offenses'. ********************************************. *** This section creates the variables for the aggregated incident level file. *******************************************. compute firearm = 0. compute knife = 0. DO REPEAT wpn = bweap1 bweap2 bweap3. if (wpn ge 30 and wpn le 95)wpn_type = 4. if (wpn = 40 or wpn = 99)wpn_type = 3. if (wpn = 20)wpn_type = 2. if (wpn le 15)wpn_type = 1. if (wpn le 15)firearm = 1. if (wpn = 20)knife = 1. END REPEAT. VALUE LABELS wpn_type 1 'Firearm' 2 'Knife or cutting instrument' 3 'Strong-arm (hands, fists, feet, etc.)' 4 'Other dangerous weapon'. freq wpn_type. compute mur = 0. compute atmp_mur = 0. compute man = 0. compute atmp_man = 0. compute rap = 0. compute atmp_rap = 0. compute rob = 0. compute rob_gun = 0. compute rob_knif = 0. compute rob_othr = 0. compute rob_sa = 0. compute aggasl = 0. compute asl_gun = 0. compute asl_knif = 0. compute asl_othr = 0. compute asl_sa = 0. compute bur = 0. compute bur_forc = 0. compute bur_nofc = 0. compute atmp_bur = 0. compute lar = 0. compute mvt = 0. compute oth_asl = 0. compute drugs = 0. if (offense = 90 and battempt = 'C')mur = 1. if (offense = 90 and battempt = 'A')atmp_mur = 1. if (offense = 110 and battempt = 'C' )rap = 1. if (offense = 110 and battempt = 'A' )atmp_rap = 1. if (offense = 120)rob = 1. if (offense = 120 and wpn_type = 1)rob_gun = 1. if (offense = 120 and wpn_type = 2)rob_knif = 1. if (offense = 120 and wpn_type = 3)rob_sa = 1. if (offense = 120 and wpn_type = 4)rob_othr = 1. if (offense = 130)aggasl = 1. if (offense = 130 and wpn_type = 1)asl_gun = 1. if (offense = 130 and wpn_type = 2)asl_knif = 1. if (offense = 130 and wpn_type = 3)asl_sa = 1. if (offense = 130 and wpn_type = 4)asl_othr = 1. if (offense = 140)bur = 1. if (offense = 140 and battempt = 'C' and bntry = 'F')bur_forc = 1. if (offense = 140 and battempt = 'C' and bntry = 'N')bur_nofc = 1. if (offense = 140 and battempt = 'A')atmp_bur = 1. if (offense >= 160 and offense le 167)lar = 1. DO REPEAT cprodes = cprodes1 cprodes2 cprodes3 cprodes4 cprodes5 cprodes6 cprodes7 cprodes8 cprodes9 cprdes10. IF (cprodes = '3') vehicle = 1. IF (cprodes = '5' or cprodes = '28' or cprodes = '37') vehicle = 2. IF (cprodes = '24') vehicle = 3. END REPEAT. VALUE LABELS vehicle 1 'Auto' 2 'Trucks and buses' 3 'Other vehicles'. if (offense = 150)mvt = 1. if (vehicle = 1)mvt_auto = cstolveh. if (vehicle = 2)mvt_bus = cstolveh. if (vehicle = 3)mvt_othr = cstolveh. if (offense = 171 or offense = 172)oth_asl = 1. if (offense = 350 or offense = 351)drugs = 1. compute vic_inj = 0. if (din_typ1 = 'B' or din_typ1 = 'I' or din_typ1 = 'L' or din_typ1 = 'M' or din_typ1 = 'T' or din_typ1 = 'U' or din_typ2 = 'B' or din_typ2 = 'I' or din_typ2 = 'L' or din_typ2 = 'M' or din_typ2 = 'T' or din_typ2 = 'U' or din_typ3 = 'B' or din_typ3 = 'I' or din_typ3 = 'L' or din_typ3 = 'M' or din_typ3 = 'T' or din_typ3 = 'U' or din_typ4 = 'B' or din_typ4 = 'I' or din_typ4 = 'L' or din_typ4 = 'M' or din_typ4 = 'T' or din_typ4 = 'U' or din_typ5 = 'B' or din_typ5 = 'I' or din_typ5 = 'L' or din_typ5 = 'M' or din_typ5 = 'T' or din_typ5 = 'U' )vic_inj = 1. compute mur_arr = 0. compute rap_arr = 0. compute rob_arr = 0. compute asl_arr = 0. compute bur_arr = 0. compute lar_arr = 0. compute mvt_arr = 0. compute oasl_arr = 0. compute sexaslt = 0. do repeat voff = voff1 to voff10. if (voff = 110 or voff = 180 or voff = 181 or voff = 182 or voff = 183 or voff = 360 or voff = 361)sexaslt = 1. end repeat. if (arroff = 90)mur_arr = 1. if (arroff = 110)rap_arr = 1. if (arroff = 120)rob_arr = 1. if (arroff = 130)asl_arr = 1. if (arroff = 140)bur_arr = 1. if (arroff >= 160 and arroff le 167)lar_arr = 1. if (arroff = 150)mvt_arr = 1. if (arroff = 171 or arroff = 172)oasl_arr = 1. ********************************************************. ***** Creates counters for the incident level file. ********************************************************. COMPUTE INC_CNT = 1. if (ori = lag(ori,1) and incnumb = lag(incnumb,1)) INC_CNT = LAG(INC_CNT) + 1. freq INC_CNT. DO IF (level = 4). COMPUTE VIC_CNT = 1. ELSE IF (level = 5). COMPUTE OFF_CNT = 1. ELSE IF (level = 6). COMPUTE ARR_CNT = 1. END IF. if (arr_cnt ge 1)clr_arr = 1. if (aclear = 'A' or aclear = 'B' or aclear = 'C' or aclear = 'D' or aclear = 'E')clr_excp = 1. if (sysmis(clr_arr) and sysmis(clr_excp))cleared = 0. if (clr_arr = 1 or clr_excp = 1)cleared = 1. Value labels cleared 1 'Cleared' 0 'Open'. compute inc_loc = bloctype. missing values battempt (' '). ***If not already added, use the following call to add all variable labels. *include 'n:\syntax files\WVIBRSlabels.sps'. *********************************************************************** * If not already sorted on ORI and incnumb sort before running the agg command. * The incident level file is created next. **********************************************************************. sort cases by ori incnumb. AGGREGATE /OUTFILE= 'n:\new flat files as of 7-07\2005newIncident.sav' /PRESORTED /BREAK=ori incnumb /ainyear = FIRST(ainyear) /ainmon = FIRST(ainmon) /ainday = FIRST(ainday) /ainhour = FIRST(ainhour) /ardi 'Flag if report date used for incident date' = first(ardi) /inc_loc 'Incident location' = first(inc_loc) /vic_cnt 'Count of victims in incident' = n(vic_cnt) /off_cnt 'Count of offenders in incident' = n(off_cnt) /arr_cnt 'Count of arrests for incident' = n(arr_cnt) /battempt 'Completed or attempted' = first(battempt) /msioff 'Most serious incident offense' = min(msvoff) /indivl 'Count of individual victims in incident' = sum(indivl) /vage65 'Count of victims age 65 and older in incident' = sum(vage65) /vage1017 'Count of victims between the ages of 10 through 17' = sum(vage1017) /vage1524 'Count of victims between the ages of 15 through 24' = sum(vage1524) /vlt18 'Count of victims under age 18' = sum(vlt18) /vadult 'Count of victims age 18 and older' = sum(vadult) /vmale 'Count of male victims in incident' = sum(vmale) /vfemale 'Count of female victims in incident' = sum(vfemale) /off65 'Count of offenders age 65 and older' = sum(off65) /off1017 'Count of offenders between the ages of 10 through 17' = sum(off1017) /off1524 'Count of offenders between the ages of 15 through 24' = sum(off1524) /offadult 'Count of offenders age 18 and older' = sum(offadult) /offmale 'Count of male offenders in incident' = sum(offmale) /offemale 'Count of female offenders in incident' = sum(offemale) /arr65 'Count of arrestees age 65 and older' = sum(arr65) /arr1017 'Count of arrestees between the ages of 10 through 17' = sum(arr1017) /arr1524 'Count of arrestees between the ages of 15 through 24' = sum(arr1524) /arr0509 'Count of arrestees between the ages of 5 through 9' = sum(arr0509) /arradult 'Count of arrestees age 18 and older' = sum(arradult) /arrmale 'Count of male arrestees in incident' = sum(arrmale) /arfemale 'Count of female arrestees in incident' = sum(arfemale) /mur 'Murder offense in incident' = sum(mur) /atmp_mur 'Attempted murder offense in incident' = sum(atmp_mur) /rap 'Rape offense in incident' = sum(rap) /atmp_rap 'Attempted rape offense in incident' = sum(atmp_rap) /rob 'Robbery offense in incident' = sum(rob) /rob_gun 'Robbery with a firearm' = sum(rob_gun) /rob_knif 'Robbery with knife or cutting instrument' = sum(rob_knif) /rob_sa 'Strong-arm robbery' = sum(rob_sa) /rob_othr 'Robbery with other dangerous bweap' = sum(rob_othr) /aggasl 'Aggravated assault offense in incident' = sum(aggasl) /asl_gun 'Aggrvated assault with a firearm' = sum(asl_gun) /asl_knif 'Aggrvated assault with knife or cutting instrument' = sum(asl_knif) /asl_sa 'Strong-arm aggrvated assault ' = sum(asl_sa) /asl_othr 'Aggrvated assault with other dangerous bweap' = sum(asl_othr) /drugs 'Drug offense in incident' = sum(drugs) /bur 'Burglary offense in incident' = sum(bur) /bur_forc 'Burglary forced entry' = sum(bur_forc) /bur_nofc 'Burglary unlawful entry no force' = sum(bur_nofc) /atmp_bur 'Attempted burglary' = sum(atmp_bur) /lar 'Larceny offense in incident' = sum(lar) /mvt 'Motor vehicle theft offense in incident' = sum(mvt) /mvt_auto 'Motor vehicle theft number of autos' = sum(mvt_auto) /mvt_bus 'Motor vehicle theft number of trucks/buses' = sum(mvt_bus) /mvt_othr 'Motor vehicle theft number of other vehicles' = sum(mvt_othr) /oth_asl 'Other assault offense in incident' = sum(oth_asl) /mur_arr 'Count of arrests for murder in incident' = sum(mur_arr) /rap_arr 'Count of arrests for rape in incident' = sum(rap_arr) /rob_arr 'Count of arrests for robbery in incident' = sum(rob_arr) /asl_arr 'Count of arrests for aggravted assault in incident' = sum(asl_arr) /bur_arr 'Count of arrests for burglary in incident' = sum(bur_arr) /lar_arr 'Count of arrests for larceny in incident' = sum(lar_arr) /mvt_arr 'Count of arrests for motor vehicle theft in incident' = sum(mvt_arr) /firearm 'Firearm used in the incident' = sum(firearm) /knife 'Knife used in the incident' = sum(knife) /vic_inj 'Number of victims injured in incident' = sum(vic_inj) /oasl_arr 'Count of arrests for other assaults in incident' = sum(oasl_arr) /sexaslt 'Count of sexual assaults in incident' = sum(sexaslt). ******************************************************************. **use to carry down the incident date to each segment before creating segment level files. IF (ori = LAG(ori) and incnumb = LAG(incnumb)) ainyear = LAG(ainyear). IF (ori = LAG(ori) and incnumb = LAG(incnumb)) ainmon = LAG(ainmon) . IF (ori = LAG(ori) and incnumb = LAG(incnumb)) ainday = LAG(ainday) . IF (ori = LAG(ori) and incnumb = LAG(incnumb)) ainhour = LAG(ainhour). IF (ori = LAG(ori) and incnumb = LAG(incnumb)) ardi = LAG(ardi). EXECUTE . *Saves each of the group A segments separately. *Also SAVE the complete data file before closing. do if (level = 2 ). xsave outfile = 'n:\new flat files as of 7-07\2005offenses.sav' /keep = level ori county incnumb ainyear to ainhour bucrcode to bhate offense wpn_type. else if (level = 3 ). xsave outfile = 'n:\new flat files as of 7-07\2005property.sav' /keep = level ori county incnumb ainyear to ainhour ctyploss to coff10. else if (level = 4 ). xsave outfile = 'n:\new flat files as of 7-07\2005victims.sav' /keep = level ori county incnumb ainyear to ainhour dvctmno to dleoka3 voff1 to voff10 msvoff estv_age. else if (level = 5 ). xsave outfile = 'n:\new flat files as of 7-07\2005offenders.sav' /keep = level ori county incnumb ainyear to ainhour eoffnumb to eid2 esto_age. else if (level = 6 ). xsave outfile = 'n:\new flat files as of 7-07\2005arrests.sav' /keep = level ori county incnumb ainyear to ainhour arrnum2 to fid2 arroff esta_age. end if. EXECUTE.