Research Question 3: Does the offender age differ by victim-offender relationship for older adult and younger victims of robbery?
The following code creates the variables necessary to answer the research question and creates a table. When using this code, be sure to insert the path and the file name of the data file to be used (which occurs numerous times in this example). The final data file is not saved, so if you want to save the variables that were created, be sure and save the file before exiting. If you need any assistance working with the syntax provided, please contact us.
The assumptions for the following example are:
|Matching the Segments
For this research question, the victim segment must be matched to the offender segment. This allows for a victim-offender interaction unit of analysis. That is, every victim is matched with each offender for which there is an offender sequence identifier. First, the victim segment (saved in Creating An Incident-Level Aggregated Flat File In SPSS) is retrieved.
The following block of code identifies the victim segment records in which robbery (voff=120) is one of the a possible ten victim offenses (voff1 to voff10) and assigns a value of 1 to this new variable (robbery). A frequency distribution is then generated for this variable.
GET FILE = 'Directory:\Path\victim segment.sav'.
DO REPEAT voff = voff1 to voff10.
IF (voff = 120)robbery = 1.
|This block of code identifies the victim segment records in which robbery is an offense and the victim is of the type "individual". These records are saved to the temporary file robvic96.sav.|
TEMPORARY.SELECT IF (robbery = 1 and v_type = 'I').
SAVE OUTFILE = 'Directory:\Path\Robvic96.sav'.
|On the victim segment, the offender sequence numbers are values in a series of up to
ten variables on a victim record. On the offender segment, the offender sequence number is
a unique variable on each offender record. The following procedures are needed to match
victim and offender segments for a victim-offender analysis.
The temporary file robvic96.sav is used to create a series of ten temporary files. First it is sorted on originating agency identifier, incident number, and victim number. Then, each set of DO IF / XSAVE OUTFILE commands creates a temporary file for each valid offender sequence number for each victim record. This set of commands is executed separately for each offender sequence number (OFNSEQ1 through OFNSEQ10). From each resulting temporary file, the other variable pairings of offender sequence number and offender victim relationship are DROPped and the remaining paired variables are RENAMEd OFNSEQ and OVR. So, from the offender sequence number 1 temporary file, the variables of offender sequence number 2-10 and offender victim relationship 2-10 are eliminated; the offender sequence number 1 variable is renamed OFNSEQ and the corresponding offender victim relationship variable is renamed OVR. This process is repeated for each offender sequence number - offender victim relationship pairing in the victim segment.
GET FILE = 'Directory:\Path\Robvic96.sav'.SORT CASES BY ori inc_num vic_num.DO IF
(ofnseq1 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq1.sav'
/DROP = ofnseq2 to ofnseq10 ovr2 to ovr10
/RENAME = (ofnseq1 ovr1 =ofnseq ovr).
DO IF (ofnseq2 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq2.sav'
/DROP = ofnseq1 ofnseq3 to ofnseq10 ovr1 ovr3 to ovr10
/RENAME = (ofnseq2 ovr2 =ofnseq ovr).
DO IF (ofnseq3 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq3.sav'
/DROP = ofnseq1 ofnseq2 ofnseq4 to ofnseq10
ovr1 ovr2 ovr4 to ovr10
/RENAME = (ofnseq3 ovr3 =ofnseq ovr).
DO IF (ofnseq4 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq4.sav'
/DROP = ofnseq1 to ofnseq3 ofnseq5 to ofnseq10
ovr1 to ovr3 ovr5 to ovr10
/RENAME = (ofnseq4 ovr4 =ofnseq ovr).
DO IF (ofnseq5 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq5.sav'
/DROP = ofnseq1 to ofnseq4 ofnseq6 to ofnseq10
ovr1 to ovr4 ovr6 to ovr10
/RENAME = (ofnseq5 ovr5 =ofnseq ovr).
DO IF (ofnseq6 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq6.sav'
/DROP = ofnseq1 to ofnseq5 ofnseq7 to ofnseq10
ovr1 to ovr5 ovr7 to ovr10
/RENAME = (ofnseq6 ovr6 =ofnseq ovr).
DO IF (ofnseq7 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq7.sav'
/DROP = ofnseq1 to ofnseq6 ofnseq8 to ofnseq10
ovr1 to ovr6 ovr8 to ovr10
/RENAME = (ofnseq7 ovr7 =ofnseq ovr).
DO IF (ofnseq8 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq8.sav'
/DROP = ofnseq1 to ofnseq7 ofnseq9 to ofnseq10
ovr1 to ovr7 ovr9 to ovr10
/RENAME = (ofnseq8 ovr8 = ofnseq ovr).
DO IF (ofnseq9 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq9.sav'
/DROP = ofnseq10 ofnseq1 to ofnseq8 ovr10 ovr1 to ovr8
/RENAME = (ofnseq9 ovr9 =ofnseq ovr).
DO IF (ofnseq10 gt 0).
XSAVE OUTFILE = 'Directory:\Path\ofnseq10.sav'
/DROP = ofnseq1 to ofnseq9 ovr1 to ovr9
/RENAME = (ofnseq10 ovr10 =ofnseq ovr).
|The 10 temporary files are concatenated, sorted by originating agency identifier, incident number, the new variable offender sequence number, and victim number, and saved into a temporary file vofnseq.sav.|
ADD FILES /FILE= 'Directory:\Path\ofnseq1.sav'
/FILE= 'Directory:\Path\ofnseq3.sav' /FILE= 'Directory:\Path\ofnseq4.sav'
SORT cases by ori inc_num ofnseq vic_num.
SAVE OUTFILE = 'Directory:\Path\vofnseq.sav'.
|This MATCH FILES command matches the active file (vofnseq.sav) for any incident in which a victim of the type "individual" reported a robbery offense with the offender segment records (established in "Creating An Incident-Level Aggregated Flat File In SPSS"). The offender file must be sorted on the variables ORI, INC_NUM, and OFNSEQ before executing the MATCH command.|
MATCH FILES /FILE=* /TABLE = 'Directory:\Path\offender segment.sav' /BY ori inc_num ofnseq.
|This RECODE groups the values for the variable offender victim relationship into six numeric categories and names the new variable ovr_rcd. DO IF selects cases in which an offender victim relationship is not applicable (i.e., not for a person offense). Not applicable and system missing are defined as MISSING VALUES, and VALUE LABELS are assigned to all relationship categories. VARIABLE LABELS assigns a variable name to ovr_rcd, and FREQuencies are requested to verify the recode. The resulting file is a victim-offender unit of analysis and is saved to robbery.sav.|
OVR ('SE','CS','PA','SB','CH','GP', 'GC','IL','SP','SC','SS','OF','XS','VO' = 1)
('AQ','FR','NE','BE','BG','CF','HR','XS','EE','ER','OK' = 2) ('RU' = 4)('ST' = 3)
(' ' = -1)INTO OVR_RCD.
DO IF ((msvoff gt 130 and msvoff lt 171) or msvoff gt 199).
RECODE ovr_rcd (-1 = 9).
MISSING VALUES ovr_rcd (-1,9).
VALUE LABELS ovr_rcd
2 'Known to Victim'
4 'Relationship Unknown' -1 'Missing Relationship Information'
9 'Not Applicable'.
VARIABLE LABELS ovr_rcd 'VICTIM TO OFFENDER RELATIONSHIP RECODED'.
RECODE v_age (0 thru 64 = 2)(65 thru 95 = 1)into vage65.
VALUE LABELS vage65 1 'Age 65 or Older'
2 'Age 64 or Younger'.
VARIABLE LABELS vage65 'Victim Age Group'.
SAVE OUTFILE = 'Directory:\Path\robbery.sav'.
|Producing the Output
The matched file robbery.sav is retrieved. The variables OVR_RCD and OFF_AGE are assigned labels on the output. TEMPORARY is used because the following procedure is for a subgroup of the data. The SELECT IF chooses records in which the offender is older than 10 years and the victim age was classifiable into one of two categories. VAGE65 is a dichotomous variable (0 = less than age 65, 1 = age 65 or older) defined in "Creating An Incident-Level Flat File in SPSS." The TABLE subcommand defines the rows as values of the offender victim relationship OVR_RCD variable, the columns as values of the victim age variable VAGE65, and the cell values as the offender age (as defined by subcommand OBSERVATION). The STATISTICS subcommand followed by the keyword MEAN requests the display of the group means for offender age in the cells.
GET FILE = 'Directory:\Path\robbery.sav'.
VARIABLE LABELS ovr_rcd 'Victim-Offender Relationship'/ off_age 'Offender Age'.
SELECT IF (off_age ge 10 and vage65 ge 0).
/FORMAT BLANK MISSING('.')
/TABLE=ovr_rcd BY vage65 > off_age
/TITLE 'Average Age of Offenders by Relationship With Victims of Robbery'
mean( off_age (f7.1) '' ).
|The output produced by these commands is a table.
The average age of offender varies by a few years or less between victim-offender relationships for victims under age 65 and victims aged 65 or older. The greatest difference, which is only 6.6 years, is for the victim-offender relationship of "known to victim" where the average offender age is 22.7 years for victims under the age of 65 and the average offender age is 29.3 years for victims age 65 or older.