Skip to content

User guide Judicial bias data

aditib738 edited this page Feb 2, 2021 · 10 revisions

This page includes sample stata code for users. The code demonstrates how to merge the various components of the judicial bias data repository to prepare a complete judicial record dataset for a particular year.

/* set global to where the public data resides */
global data [fill in path]

/* for this demonstration, let's start with case data for year 2018 */
use $data/cases/cases_2018, clear

/* is it unique on ddl-case id? */
isid ddl_case_id

/* extract act, section, criminal indicator details for this dataset */
merge 1:1 ddl_case_id using $data/acts_sections, gen(act_merge)
drop if act_merge == 2
/* act_merge == 2 are instances where act-section information */
/* is not available on e-courts based on manual verification */

/* extract judge-id using the judge key */
merge 1:1 ddl_case_id using $data/keys/judge_case_merge_key, gen(judge_merge)
drop if judge_merge == 2
/* note that the judge-case merge key only pertains to criminal cases */

/* rename judge id -- assuming here you want to match with judge who was first assigned the case */
ren ddl_judge_filing_id ddl_judge_id
/* note: if instead, you wanted to match with judge who decided the case, use ddl_judge_decision_id above */

/* use the judge id to get judge details */
merge m:1 ddl_judge_id using $data/judges_clean, keep(master match) nogen

/* now extract the string value of the following variables */
foreach var in act section{
  merge m:1 `var' using $data/keys/`var'_key, gen(`var'_key_merge) keep(master match) keepusing (`var'_s)
}

/* merge to get purpose name, type_name and disposition string values */
foreach var in purpose_name type_name disp_name{
  merge m:1 `var' year using $data/keys/`var'_key, gen(`var'_key_merge) keep(master match) keepusing (`var'_s)
}

/* merge to get state name, district name, and court name */
merge m:1 state_code year using $data/keys/cases_state_key, nogen
merge m:1 state_code dist_code year using $data/keys/cases_district_key, nogen
merge m:1 state_code dist_code court_no year using $data/keys/cases_court_key, nogen

/* order */
order *merge, last

/* compress and saves */
compress
save [fill in path], replace
Clone this wiki locally