# Searchable Codebooks

    library(rfars)
    library(dplyr)
    library(stringr)

`rfars` comes pre-loaded with searchable codebooks, compiled from SAS format files and the User Manuals (see: FARS Analytical User’s Manual and CRSS Analytical User’s Manual).

Access the codebooks in RStudio with:

    View(rfars::fars_codebook)
    View(rfars::gescrss_codebook)

It can be helpful to search the codebooks for certain concepts. The examples below illustrate the content of the codebooks and how variables change over time.

Here we search for the word alcohol in any of the codebook fields, including the names of tables, various versions of variable names, the definition, all value labels, and additional information from the User Manual if present.

    cb <- rfars::fars_codebook %>% filter(if_any(everything(), ~ str_detect(., "alcohol")))

    distinct(cb, source, file, name_ncsa, name_rfars, label, Definition, `Additional Information`) %>%
      knitr::kable(format = "html")

source | file | name_ncsa | name_rfars | label | Definition | Additional Information
--- | --- | --- | --- | --- | --- | ---
FARS | vehicle | DR_DRINK | dr_drink | Driver Drinking | This data element records whether the driver was drinking. | This data element is derived from data elements in the Vehicle and Person data files. Data are analyzed and if there is "sufficient information" to conclude that a driver was drinking, i.e., positive BAC data or police-reported alcohol involvement, then a driver is classified as drinking. A driver is classified as drinking (alcohol-involved) if the driver has (1) police-reported alcohol involvement, or (2) a positive alcohol test result. A driver who is charged with an alcohol violation does not by itself make the driver a "drinking driver" by this definition. Note that alcohol data is often missing. For that reason, this data element may under-count the actual number of drinking drivers.
FARS | person | DRINKING | drinking | Police Reported Alcohol Involvement | This data element records whether alcohol was involved for this person and reflects the judgment of law enforcement. | This data element does not indicate that alcohol was a cause of the crash. If a police crash report indicates that opened or unopened alcohol bottles were found in the vehicle, then this information does not by itself constitute involvement. Prior to 2019 the Data Element ID was P16/NM15. From 2019-2021 the Element Data ID was P16/NM16.
FARS | person | ALC_STATUS | alc_status | Alcohol Test- Status | This data element identifies whether an alcohol test was given to this person. | Prior to 2019 the Data Element ID was P18A/NM17A. From 2019-2021 the Data Element ID was P18A/NM18A.
FARS | person | ATST_TYP | atst_typ | Alcohol Test- Type | This data element identifies the type of alcohol test that was given to this person. | Prior to 2019 the Data Element ID was P18B/NM17B. From 2019-2021 the Data Element ID was P18B/NM18B.
FARS | person | ALC_RES | alc_res | Alcohol Test- Result | This data element identifies the alcohol test result for this person. | NA
FARS | distract | MDRDSTRD | mdrdstrd | Driver Distracted By | NA | Distraction from the primary task of driving occurs when drivers divert their attention from the driving task to some other activity. Also, driving while daydreaming or lost in thought is identified as distracted driving by NHTSA. Physical conditions/impairments (fatigue, alcohol, medical condition, etc.) or psychological states (anger, emotional, depressed, etc.) are not identified as distractions by NHTSA. Although the attribute 1 (Looked but Did Not See) was included in this element, this attribute is not considered a distraction and therefore should not be included in any distraction analysis.
FARS | violatn | MVIOLATN | mviolatn | Violations Charged | This data element documents the violations, citations, or infractions of the Vehicle Code issued on the police crash report for this driver in this crash, regardless of whether the driver survived the crash. | Prior to 2010 this data element was in the Vehicle data file. In 2010 this data element changed to identify all violations charged in the crash and was therefore moved here to its own data file.
FARS | vehicle | PREV_SUS1 | prev_sus1 | Previous Underage Administrative Per Se for BAC | This data element records any underage pre-conviction administrative license suspension, revocation, or withdrawal in the 5 years prior to the crash date including those for zero-tolerance alcohol violations while driving or refusing to submit to chemical testing. This element is only for administrative actions associated with alcohol. These are NOT BAC convictions. | Prior to 2015 the time frame for this data element was any occurrence within 3 years of the crash date.
FARS | vehicle | PREV_SUS2 | prev_sus2 | Previous Administrative Per Se for BAC (Not Underage) | This data element records the count of previous pre-conviction administratively imposed suspensions, revocations, or withdrawals within the 5 years prior to the crash date for driving with a BAC above a specified limit or refusing to submit to chemical testing. This element is only for administrative actions associated with alcohol. These are NOT BAC convictions. | Prior to 2015 the time frame for this data element was any occurrence within 3 years of the crash date.
FARS | distract | DRDISTRACT | drdistract | Driver Distracted By | NA | Distraction from the primary task of driving occurs when drivers divert their attention from the driving task to some other activity. Also, driving while daydreaming or lost in thought is identified as distracted driving by NHTSA. Physical conditions/impairments (fatigue, alcohol, medical condition, etc.) or psychological states (anger, emotional, depressed, etc.) are not identified as distractions by NHTSA. Although the attribute 1 (Looked but Did Not See) was included in this element, this attribute is not considered a distraction and therefore should not be included in any distraction analysis.
FARS | violatn | VIOLATION | violation | Violations Charged | This data element documents the violations, citations, or infractions of the Vehicle Code issued on the police crash report for this driver in this crash, regardless of whether the driver survived the crash. | Prior to 2010 this data element was in the Vehicle data file. In 2010 this data element changed to identify all violations charged in the crash and was therefore moved here to its own data file.

The `drinking` variable changed in a very minor way:

    filter(cb, name_rfars == "drinking") %>%
      distinct(name_rfars, value_label, `2014`, `2015`, `2016`, `2017`, `2018`, `2019`, `2020`, `2021`, `2022`, `2023`) %>%
      knitr::kable(format = "html")

name_rfars | value_label | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
drinking | No (Alcohol Not Involved) | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
drinking | Yes (Alcohol Involved) | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
drinking | Not Reported | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
drinking | Unknown (Police Reported) | 1 | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA
drinking | Reported as Unknown | NA | NA | NA | NA | 1 | 1 | 1 | 1 | 1 | 1

But the variable for driver distraction changed names in 2020:

    filter(cb, name_rfars %in% c("mdrdstrd", "drdistract")) %>%
      distinct(name_rfars, value_label, `2014`, `2015`, `2016`, `2017`, `2018`, `2019`, `2020`, `2021`, `2022`, `2023`) %>%
      arrange(value_label, name_rfars) %>%
      knitr::kable(format = "html")

name_rfars | value_label | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
drdistract | Adjusting Audio Or Climate Controls | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Adjusting Audio Or Climate Controls | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | By a Moving Object in Vehicle | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | By a Moving Object in Vehicle | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | By Other Occupant(s) | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | By Other Occupant(s) | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Careless/Inattentive | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Careless/Inattentive | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Distracted by Outside Person, Object or Event | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Distracted by Outside Person, Object or Event | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Distraction (Distracted), Details Unknown | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Distraction (Distracted), Details Unknown | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Distraction/Careless | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Distraction/Careless | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Distraction/Inattention | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Distraction/Inattention | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Eating or Drinking | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Eating or Drinking | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Inattention (Inattentive), Details Unknown | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Inattention (Inattentive), Details Unknown | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
mdrdstrd | Looked But Did Not See | 1 | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA
drdistract | Lost in Thought / Day dreaming | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Lost in Thought / Day dreaming | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | No Driver Present/Unknown if Driver present | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | No Driver Present/Unknown if Driver present | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Not Distracted | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Not Distracted | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | Not Reported | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Not Reported | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
mdrdstrd | Other Cellular Phone Related | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA | NA
mdrdstrd | Other Distraction | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA | NA
drdistract | Other Distraction [Specify:] | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Other Distraction [Specify:] | NA | NA | NA | NA | NA | 1 | NA | NA | NA | NA
drdistract | Other Mobile Phone Related | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Other Mobile Phone Related | NA | NA | NA | NA | NA | 1 | NA | NA | NA | NA
drdistract | Reported as Unknown if Distracted | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Reported as Unknown if Distracted | NA | NA | NA | NA | 1 | 1 | NA | NA | NA | NA
drdistract | Smoking Related | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | Smoking Related | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
mdrdstrd | Unknown if Distracted | 1 | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA
mdrdstrd | While Manipulating Cellular Phone | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA | NA
drdistract | While Manipulating Mobile Phone | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | While Manipulating Mobile Phone | NA | NA | NA | NA | NA | 1 | NA | NA | NA | NA
mdrdstrd | While Talking or Listening to Cellular Phone | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA | NA
drdistract | While Talking or Listening to Mobile Phone | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | While Talking or Listening to Mobile Phone | NA | NA | NA | NA | NA | 1 | NA | NA | NA | NA
drdistract | While Using or Reaching for Device/Object Brought into Vehicle | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | While Using or Reaching for Device/Object Brought into Vehicle | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA
drdistract | While Using Other Component/Controls Integral to Vehicle | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | 1
mdrdstrd | While Using Other Component/Controls Integral to Vehicle | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA | NA | NA

As another example, the `per_typ` variable has undergone more substantial changes over time.

    filter(rfars::fars_codebook, name_rfars == "per_typ") %>%
      distinct(name_rfars, value_label, `2014`, `2015`, `2016`, `2017`, `2018`, `2019`, `2020`, `2021`, `2022`, `2023`) %>%
      arrange(value_label, name_rfars) %>%
      knitr::kable(format = "html")

name_rfars | value_label | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
per_typ | Bicyclist | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
per_typ | Driver of a Motor Vehicle In-Transport | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
per_typ | Occupant of a Motor Vehicle Not In- Transport | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
per_typ | Occupant of a Non-Motor Vehicle Transport Device | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
per_typ | Other Cyclist | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA
per_typ | Other Pedalcyclist | NA | NA | NA | NA | NA | NA | NA | NA | 1 | 1
per_typ | Passenger of a Motor Vehicle In-Transport | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
per_typ | Pedestrian | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
per_typ | Person In/On a Building | NA | NA | NA | NA | NA | NA | NA | NA | 1 | 1
per_typ | Person on a Personal Conveyance | NA | NA | NA | NA | NA | NA | NA | NA | 1 | 1
per_typ | Person on Motorized Personal Conveyance | NA | NA | NA | NA | NA | NA | 1 | 1 | NA | NA
per_typ | Person on Motorized Personal Conveyance | NA | NA | NA | NA | NA | NA | NA | NA | 1 | NA
per_typ | Person on Non-Motorized Personal Conveyance | NA | NA | NA | NA | NA | NA | 1 | 1 | 1 | NA
per_typ | Person on Personal Conveyance, Unknown if Motorized or Non-Motorized | NA | NA | NA | NA | NA | NA | 1 | 1 | NA | NA
per_typ | Person on Personal Conveyance, Unknown if Motorized or Non-Motorized*/ | NA | NA | NA | NA | NA | NA | NA | NA | 1 | NA
per_typ | Person on Personal Conveyances | NA | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA
per_typ | Persons In/On Buildings | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | NA | NA
per_typ | Persons on Personal Conveyances | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA
per_typ | Unknown Occupant Type in a Motor Vehicle In- Transport | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1
per_typ | Unknown Type of Non-Motorist | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1

Users of rfars and FARS data in general are strongly encouraged to User Manuals for further guidance.