R/make_sps/make_arrest_post_2020_sps.R

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

agency_header_cols_post_2020 <- c("1",
                                  "2-3",
                                  "4-10",
                                  "11-12",
                                  "13",
                                  "14-15",
                                  "16-18",
                                  "19",
                                  "20",
                                  "21",
                                  "22",
                                  "23-25",
                                  "26-27",
                                  "28-32",
                                  "33-35",
                                  "36-39",
                                  "40",
                                  "41-50",
                                  "51-109",
                                  "110",
                                  "111-135")

agency_header_names_post_2020 <- c("identifier_code",
                                   "state",
                                   "ori",
                                   "population_group",
                                   "country_division",
                                   "year",
                                   "msa",
                                   "suburban",
                                   "not_used1",
                                   "report_indication",
                                   "adjustment",
                                   "offense",
                                   "not_used2",
                                   "sequence_number",
                                   "county",
                                   "not_used3",
                                   "core_city",
                                   "population",
                                   "not_used4",
                                   "agency_count",
                                   "agency_name")


agency_header_values_post_2020 <- c(state_group_division_value_labels,
                                    "identifier_code = ",
                                    "3 = ASR master file",
                                    "suburban = ",
                                    "1 = suburban",
                                    "0 = non-suburban",
                                    "report_indication = ",
                                    "0 = juvenile and adult reported",
                                    "1 = juvenile only reported",
                                    "2 = adult only reported",
                                    "3 = not reported",
                                    "adjustment = ",
                                    "0 = age, race, and ethnic origin reported",
                                    "1 = no age reported",
                                    "2 = no race reported",
                                    "3 = no ethnic origin reported",
                                    "4 = no race or ethnic origin reported",
                                    "5 = no age or ethnic origin reported",
                                    "6 = no age or race reported",
                                    "core_city = ",
                                    "Y = agency is core city of an MSA",
                                    "N = agency is not a core city of an MSA")


detail_header_cols_post_2020 <- c("1",
                                  "2-3",
                                  "4-10",
                                  "11-12",
                                  "13",
                                  "14-15",
                                  "16-18",
                                  "19",
                                  "20",
                                  "21",
                                  "22",
                                  "23-25",
                                  "26-40",
                                  "41-49",
                                  setup_num_adder("41-49", 9, 55))


ages <- c("under_10",
          "10_12",
          "13_14",
          "15",
          "16",
          "17",
          "18",
          "19",
          "20",
          "21",
          "22",
          "23",
          "24",
          "25_29",
          "30_34",
          "35_39",
          "40_44",
          "45_49",
          "50_54",
          "55_59",
          "60_64",
          "over_64")

race_ethnicity <- c("white",
                    "black",
                    "amer_ind",
                    "asian",
                    "hispanic",
                    "non_hisp")

detail_header_names_post_2020 <- c("identifier_code",
                                   "state",
                                   "ori",
                                   "population_group",
                                   "country_division",
                                   "year",
                                   "msa",
                                   "card_1_indicator",
                                   "card_2_indicator",
                                   "card_3_indicator",
                                   "adjustment",
                                   "offense_code",
                                   "not_used",
                                   paste0("male_", ages),
                                   paste0("female_", ages),
                                   paste0("juv_", race_ethnicity),
                                   paste0("adult_", race_ethnicity))


detail_header_values_post_2020 <- c(state_group_division_value_labels,
                                    "identifier_code = ",
                                    "3 = ASR master file",
                                    "card_1_indicator = ",
                                    "0 = no adult male reported",
                                    "1 = adult male reported",
                                    "card_2_indicator = ",
                                    "0 = no adult female reported",
                                    "1 = adult female reported",
                                    "card_3_indicator = ",
                                    "0 = no juvenile reported",
                                    "1 = juvenile reported",
                                    "adjustment = ",
                                    "0 = age, race, and ethnic origin reported",
                                    "1 = no age reported",
                                    "2 = no race reported",
                                    "3 = no ethnic origin reported",
                                    "4 = no race or ethnic origin reported",
                                    "5 = no age or ethnic origin reported",
                                    "6 = no age or race reported",
                                    "offense_code = ",
                                    "000 = header record",
                                    "011 = murder",
                                    "012 = manslaught_neg",
                                    "020 = rape",
                                    "030 = robbery",
                                    "040 = agg_assault",
                                    "050 = burglary",
                                    "060 = theft",
                                    "070 = mtr_veh_theft",
                                    "080 = oth_assault",
                                    "090 = arson",
                                    "100 = forgery",
                                    "110 = fraud",
                                    "120 = embezzlement",
                                    "130 = stolen_prop",
                                    "140 = vandalism",
                                    "150 = weapons",
                                    "160 = prostitution",
                                    "161 = prostitution_pro",
                                    "162 = prostitution_ass",
                                    "163 = prostitution_pur",
                                    "170 = oth_sex_off",
                                    "18 = total_drug",
                                    "180 = sale_drug_total",
                                    "181 = sale_heroin_coke",
                                    "182 = sale_cannabis",
                                    "183 = sale_synth_narc",
                                    "184 = sale_other_drug",
                                    "185 = poss_drug_total",
                                    "186 = poss_heroin_coke",
                                    "187 = poss_cannabis",
                                    "188 = poss_synth_narc",
                                    "189 = poss_other_drug",
                                    "19 = gamble_total",
                                    "191 = gamble_bookmake",
                                    "192 = gamble_lottery",
                                    "193 = gamble_other",
                                    "200 = family_off",
                                    "210 = dui",
                                    "220 = liquor",
                                    "230 = drunkenness",
                                    "240 = disorder_cond",
                                    "250 = vagrancy",
                                    "260 = all_other",
                                    "270 = suspicion",
                                    "280 = curfew_loiter",
                                    "290 = runaways",
                                    "301 = human_traf_sex",
                                    "302 = human_traf_serv")




setwd(here::here("setup_files"))
asciiSetupReader::make_sps_setup(file_name     = "arrests_agency_header_post_2020",
                                 col_positions = agency_header_cols_post_2020,
                                 col_labels    = agency_header_names_post_2020,
                                 value_labels  = agency_header_values_post_2020)

asciiSetupReader::make_sps_setup(file_name     = "arrests_detail_header_post_2020",
                                 col_positions = detail_header_cols_post_2020,
                                 col_labels    = detail_header_names_post_2020,
                                 value_labels  = detail_header_values_post_2020)
jacobkap/crime_data documentation built on April 16, 2023, 11:58 p.m.