R/make_sps/make_hate_crime_batch_header_sps.R

source(here::here('R/make_sps/make_sps_utils.R'))

batch_header_values <- c(state_group_division_value_labels,
                         "country_region = ",
                         "1 = North East",
                         "2 = North Central",
                         "3 = South",
                         "4 = West",
                         "agency_indicator = ",
                         "0 = Covered-by Another Agency",
                         "1 = City",
                         "2 = County",
                         "3 = University or College",
                         "4 = State Police",
                         "core_city = ",
                         "Y = Yes",
                         "N = No",
                         "agency_nibrs_flag = ",
                         " = Inactive",
                         "A = Active",
                         # State quarter activity
                         "state_first_quarter_activity = ",
                         "Z = Zero-Report was submitted",
                         "I = Incident Report was submitted",
                         " = No hate crime information",
                         "state_second_quarter_activity = ",
                         "Z = Zero-Report was submitted",
                         "I = Incident Report was submitted",
                         " = No hate crime information",
                         "state_third_quarter_activity = ",
                         "Z = Zero-Report was submitted",
                         "I = Incident Report was submitted",
                         " = No hate crime information",
                         "state_fourth_quarter_activity = ",
                         "Z = Zero-Report was submitted",
                         "I = Incident Report was submitted",
                         " = No hate crime information",
                         # Federal quarter activity
                         "federal_first_quarter_activity = ",
                         "I = Incident report was submitted",
                         " = No hate crime information",
                         "federal_second_quarter_activity = ",
                         "I = Incident report was submitted",
                         " = No hate crime information",
                         "federal_third_quarter_activity = ",
                         "I = Incident report was submitted",
                         " = No hate crime information",
                         "federal_fourth_quarter_activity = ",
                         "I = Incident report was submitted",
                         " = No hate crime information")

batch_header_values_labels <- c(state_group_division_value_labels,
                                batch_header_values)



col_positions <- c("1-2",
                   "3-4",
                   "5-13",
                   "14-25",
                   "26-33",
                   "34-41",
                   "42-71",
                   "72-73",
                   "74-75",
                   "76",
                   "77",
                   "78",
                   "79",
                   "80-88",
                   "89-92",
                   "93-96",
                   "97",
                   "98-105",
                   "106-114",
                   "115-117",
                   "118-120",
                   "121-129",
                   "130-138",
                   "139-141",
                   "142-144",
                   "145-153",
                   "154-162",
                   "163-165",
                   "166-168",
                   "169-177",
                   "178-186",
                   "187-189",
                   "190-192",
                   "193-201",
                   "202-210",
                   "211-213",
                   "214-216",
                   "217-225",
                   "226-229",
                   "230",
                   "231",
                   "232",
                   "233",
                   "234",
                   "235",
                   "236",
                   "237",
                   "238-267",
                   "268-270",
                   "271-273",
                   "274-276",
                   "277-279",
                   "280-282")

col_labels <- c("hate_crime_record_type",
                "state",
                "ori9",
                "incident_number",
                "date_ori_was_added",
                "date_ori_went_nibrs",
                "city_name",
                "state_abbreviation",
                "population_group",
                "country_division",
                "country_region",
                "agency_indicator",
                "core_city",
                "covered_by_ori",
                "fbi_field_office",
                "judicial_district",
                "agency_nibrs_flag",
                "agency_inactive_date",

                "current_population_1",
                "ucr_county_code_1",
                "msa_code_1",
                "last_population_1",

                "current_population_2",
                "ucr_county_code_2",
                "msa_code_2",
                "last_population_2",

                "current_population_3",
                "ucr_county_code_3",
                "msa_code_3",
                "last_population_3",

                "current_population_4",
                "ucr_county_code_4",
                "msa_code_4",
                "last_population_4",

                "current_population_5",
                "ucr_county_code_5",
                "msa_code_5",
                "last_population_5",
                "year",
                "state_first_quarter_activity",
                "state_second_quarter_activity",
                "state_third_quarter_activity",
                "state_fourth_quarter_activity",
                "federal_first_quarter_activity",
                "federal_second_quarter_activity",
                "federal_third_quarter_activity",
                "federal_fourth_quarter_activity",
                "agency_name",
                "fips_county_code_1",
                "fips_county_code_2",
                "fips_county_code_3",
                "fips_county_code_4",
                "fips_county_code_5")

setwd(here::here("setup_files"))
make_sps_setup(file_name     = "ucr_hate_crimes_batch_header.sps",
               col_positions = col_positions,
               col_labels    = col_labels,
               value_labels  = batch_header_values_labels)
jacobkap/crime_data documentation built on April 16, 2023, 11:58 p.m.