South Carolina Department of Public Safety and the University of South Carolina Download SPSS syntax

This table looks at the occurrence of juvenile firearm violence, comparing time-of-day categories in weekends and weekdays during the school year.  When using this code, be sure to insert the path and the file name of the data file to be used, as well as the directory and file name for saving.  If you need any assistance working with the syntax provided, please contact us.

The assumptions for the following example of code are:
  1. The data file was created as described in "Reading A Multi-Level Data File."
  2. An aggregated flat file was created as described in "Creating An Incident-Level Aggregated Flat File in SPSS"; and
  3. The individual data segments were saved in separate files as described in "Creating An Incident-Level Aggregated Flat File in SPSS".

Preparing the File.  The unit of analysis for this research question is incident.  The incident-level flat file can be used rather than multiple segments (administrative, victim, offense) because the variables needed were created with the aggregate command in the Creating An Incident-Level Aggregated Flat File procedure.   First, a variable called VIOL_OFF is created from the most serious incident offense.  The IF transformation then selects all cases where the most serious incident offense is less than or equal to a value of 130 (murder, rape, robbery, aggravated assault).  The number 1 represents the presence of a Part 1 violent index offense and the number 0 represents the absence of a Part 1 violent offense.

GET FILE='Directory\Path\incident 1999.sav'.
COMPUTE viol_off = 0.
IF (msioff le 130) viol_off = 1.

The TEMPORARY command, followed by the SELECT IF command, chooses records based on whether the offender's age, violent offense, and firearm variables are all greater than or equal to one.

SELECT IF (off1017 ge 1 AND viol_off = 1 AND firearm ge 1).
SAVE OUTFILE='Directory\Path\Juv viol firearm incidents.sav'.

The USEALL defines a USE range starting with the first observation and ending with the last observation in the series.  This COMPUTE illustrates the use of a filter to limit the analysis to only those incidents that occurred during the school year.

GET FILE='Directory\Path\Juv viol firearm incidents.sav'.
COMPUTE filter_$=(((inc_mo >=1 & inc_mo <=6) or (inc_mo >=9 & inc_mo <=12))
     and rptdate = ' ').
VARIABLE LABEL filter_$ 0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.

The first COMPUTE creates a weekday variable.  The DATE.DMY puts the variables INC_DY, INC_MO, and INC_YR into a date format (the data are initially set up with an incident's day, month and year as separate variables).  XDATE.WKDAY then extracts the weekday of the incident from the date format with the values 1 through 7 representing the days of the week.  VALUE LABELS are assigned to the variable wkday.

The second COMPUTE created a WEEKEND variable that is set to a value of 1.  IF the WKDAY variable is greater than 2 and less than 6, the variable WEEKEND is equal to 2.   VALUE LABELS are also assigned.

COMPUTE wkday = XDATE.WKDAY(DATE.DMY(inc_dy,inc_mo,inc_yr)).
VALUE LABELS wkday 1 'Sunday'  2 'Monday'  3 'Tuesday'  4 'Wednesday'   5 'Thursday'
   6 'Friday'  7 'Saturday'.

COMPUTE weekend = 1.
IF (wkday ge 2 and wkday le 6)weekend = 2.
VALUE LABELS weekend 1 'Weekend'  2 'Weekday'.

Only the incidents with an actual date and time are selected for analysis; incidents coded with a "report" date are excluded.  This example also assumes that the INC_HR is reported correctly; incidents at zero hours, representing the midnight hour, are included despite possible data quality issues (see the Data Quality section for a discussion of this issue).

DO IF (rptdate = ' ').
RECODE inc_hr (0 thru 6 = 1)(7 = 2)(8 thru 11 =3)(12 thru 14 = 4)(15 thru 17 = 5)
  (18 thru 20 = 6)(21 thru 23 = 7)INTO time.
VALUE LABELS time 1 'Mid - 6:59 am'  2 '7 -7:59 am'  3 '8 - 11:59 am' 4 'Noon - 2:59 pm'
  5 '3 - 5:59 pm'  6 '6 - 8:59 pm'  7 '9 - 11:59 pm'.

Producing the Output.  The output is defined as a table that displays the time of day groups by the days of the week.  The totals are shown for both columns and rows.  Percentages are calculated for both day of week and time period.

  /FTOTAL=$t000002 BY weekend + $t000001
  CPCT (weekend(pct5.1) 'Col %':weekend)
  /TITLE 'Time of Juvenile Firearm Violence During the School Year' '(Calendar Year 1999)'.

Using 1999 NIBRS data, the resulting table looks like this:

time_juvenile_firearm.jpg (50053 bytes)