Skip to content

brycewang-stanford/Auto-Empirical-Research-Skills / skills/18-jusi-aalto-stata-accounting-research

stata-accounting-research

Unverified

STATA code pattern library for empirical archival accounting research. Provides tested syntax from 126 peer-reviewed JAR (Journal of Accounting Research) replication files (2017-2025). Use when the user asks procedural questions like "How do I implement [method]?" or "Show me code for [technique]" — including: entropy balancing, propensity score matching (PSM), difference-in-differences (DiD), regression discontinuity (RDD), instrumental variables (IV), event studies (CAR/BHAR), survival analysis, Fama-MacBeth regressions, bootstrap, quantile regression, reghdfe/xtreg/areg, clustering standard errors, fixed effects, esttab/outreg2 table formatting, winsorization, leads/lags. Users can specify their variables (e.g., treatment, outcomes, controls) and receive adapted syntax. NOTE: This skill provides code patterns from published papers, not research design advice.

FileKindSize
README-original.mdmarkdown2.9 KB
SKILL.mdskill md4.8 KB
references/JAR_55_bbcl.doother59.1 KB
references/JAR_55_chaplinksy-hanley-moon.doother46.3 KB
references/JAR_55_clm.doother95.1 KB
references/JAR_55_elw.doother58.0 KB
references/JAR_55_hlsw.doother104.1 KB
references/JAR_55_kks.doother365.5 KB
references/JAR_55_lzz.doother25.5 KB
references/JAR_55_madsen.doother307.5 KB
references/JAR_55_mr.doother41.5 KB
references/JAR_56_al.doother75.3 KB
references/JAR_56_bch.doother13.5 KB
references/JAR_56_blv.doother24.6 KB
references/JAR_56_csmw.doother27.6 KB
references/JAR_56_en.doother21.2 KB
references/JAR_56_granja.doother107.9 KB
references/JAR_56_htw.doother18.6 KB
references/JAR_56_kmt.doother5.6 KB
references/JAR_56_ksvw.doother8.0 KB
references/JAR_56_llz.doother3.1 KB
references/JAR_56_ls.doother147.5 KB
references/JAR_56_lv2018.doother123.7 KB
references/JAR_57_bht.doother24.4 KB
references/JAR_57_bl.doother22.6 KB
references/JAR_57_bw.doother263.2 KB
references/JAR_57_cct.doother347.1 KB
references/JAR_57_cgw.doother195.8 KB
references/JAR_57_hcp.doother38.0 KB
references/JAR_57_honigsberg.doother99.5 KB
references/JAR_57_lehmann.doother112.8 KB
references/JAR_57_lm.doother85.5 KB
references/JAR_58_bsz.doother36.9 KB
references/JAR_58_ckm.doother52.3 KB
references/JAR_58_eyring.doother58.1 KB
references/JAR_58_gj.doother187.5 KB
references/JAR_58_gsz.doother121.6 KB
references/JAR_58_htyz.doother30.9 KB
references/JAR_58_jansen.doother99.5 KB
references/JAR_58_joshi.doother43.0 KB
references/JAR_58_kvy.doother19.5 KB
references/JAR_58_msz.doother35.0 KB
references/JAR_58_rauter.doother433.2 KB
references/JAR_58_wy.doother64.5 KB
references/JAR_58_zz.doother125.5 KB
references/JAR_59_breuer.doother826.9 KB
references/JAR_59_ctv.doother383.7 KB
references/JAR_59_dess.doother78.4 KB
references/JAR_59_hmo.doother351.6 KB
references/JAR_60_abkp.doother129.9 KB
references/JAR_60_alv.doother35.4 KB
references/JAR_60_at.doother38.5 KB
references/JAR_60_barrios.doother119.6 KB
references/JAR_60_bbin.doother72.9 KB
references/JAR_60_bdem.doother11.6 KB
references/JAR_60_bl.doother43.5 KB
references/JAR_60_bmsw.doother7.7 KB
references/JAR_60_cc.doother20.1 KB
references/JAR_60_cpss.doother15.4 KB
references/JAR_60_cstv.doother175.3 KB
references/JAR_60_dg.doother19.9 KB
references/JAR_60_duguay.doother8.0 KB
references/JAR_60_fhl.doother71.3 KB
references/JAR_60_gls.doother37.0 KB
references/JAR_60_hmryz.doother28.6 KB
references/JAR_60_hst.doother18.3 KB
references/JAR_60_kt.doother10.4 KB
references/JAR_60_mliu.doother28.3 KB
references/JAR_60_nrwx.doother14.6 KB
references/JAR_60_ptwy.doother26.6 KB
references/JAR_60_skim.doother14.7 KB
references/JAR_61_bcdr.doother524.9 KB
references/JAR_61_bkr.doother51.6 KB
references/JAR_61_bls.doother79.2 KB
references/JAR_61_bo.doother29.7 KB
references/JAR_61_ccm.doother48.7 KB
references/JAR_61_cdss.doother3.9 KB
references/JAR_61_cfhll.doother47.1 KB
references/JAR_61_cfmp.doother12.7 KB
references/JAR_61_ckor.doother77.5 KB
references/JAR_61_cllw.doother11.2 KB
references/JAR_61_clm.doother11.0 KB
references/JAR_61_deller.doother368.9 KB
references/JAR_61_dlrtw.doother30.6 KB
references/JAR_61_dlz.doother13.6 KB
references/JAR_61_drs.doother15.8 KB
references/JAR_61_ds.doother197.5 KB
references/JAR_61_glt.doother1.9 KB
references/JAR_61_gyz.doother7.5 KB
references/JAR_61_ll.doother89.3 KB
references/JAR_61_lszz.doother15.9 KB
references/JAR_61_os.doother128.9 KB
references/JAR_61_zureich.doother22.2 KB
references/JAR_62_1_bdsy_banerjee_etal.doother6.6 KB
references/JAR_62_1_bhs_bouwens_etal.doother59.7 KB
references/JAR_62_1_gsz_gu_sun_zhou.doother46.6 KB
references/JAR_62_2_dgzz_defranco_etal.doother1.8 KB
references/JAR_62_2_gmp_grewal_etal.doother37.2 KB
references/JAR_62_2_xyz_xin_etal.doother25.3 KB
references/JAR_62_3_bht_bloomfield_etal.doother16.0 KB
references/JAR_62_3_ccz_cheynel_etal.doother23.3 KB
references/JAR_62_3_kim.doother2.6 KB
references/JAR_62_3_rr_raghunandan_ruchti.doother15.5 KB
references/JAR_62_4_bd_breuer_dehaan.doother15.3 KB
references/JAR_62_4_cc_cadman_carrizosa.doother20.1 KB
references/JAR_62_4_kmsv_kohler_etal.doother91.5 KB
references/JAR_62_4_mps_marra_etal.doother68.0 KB
references/JAR_62_4_raghunandan.doother50.0 KB
references/JAR_62_4_stv_sran_etal.doother41.1 KB
references/JAR_62_4_xu.doother49.4 KB
references/JAR_62_5_aov_abraham_etal.doother418.9 KB
references/JAR_62_5_gibbons.doother80.1 KB
references/JAR_62_5_jiang.doother114.3 KB
references/JAR_62_5_kstz_krueger_etal.doother26.7 KB
references/JAR_62_5_llz_li_lou_zhang.doother6.2 KB
references/JAR_62_5_lrst_lins_etal.doother66.2 KB
references/JAR_62_5_lswy_lin_etal.doother85.2 KB
references/JAR_62_5_lw_li_wang.doother16.6 KB
references/JAR_63_1_blmv_bastiaansen_etal.doother18.5 KB
references/JAR_63_1_cvw_chen_etal.doother61.2 KB
references/JAR_63_1_fgr_frankel_etal.doother30.3 KB
references/JAR_63_1_hrsx_huang_etal.doother35.5 KB
references/JAR_63_1_jia.doother12.0 KB
references/JAR_63_2_bcrw_bakke_etal.doother271.3 KB
references/JAR_63_2_dlr_desimone_etal.doother83.5 KB
references/JAR_63_2_mqtz_mao_etal.doother94.2 KB
references/JAR_63_2_npstv_nessa_etal.doother7.0 KB
references/JAR_63_3_breuer.doother51.4 KB
references/REFERENCES.mdmarkdown30.7 KB

references/JAR_58_eyring.do

View on GitHub
********************************************************************************************************************************************
*
*  Disclosing Physician Ratings: Performance Effects and the Difficulty of Altering Ratings Consensus
*
*  Henry Eyring
*
*  Steps and program for main empirical analyses
*  Data are confidential and provided by University of Utah Health Care as described in the attached datasheet
*
********************************************************************************************************************************************


********************************************************************************************************************************************
*
** Table 3 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Data.dta", replace

* Code indicator for gender as 1 if Female.
gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Show coefficients on year dummies alone.

reg rating i.year_code, cluster(specialty)

* Estimate effect of disclosure on Rating (without controls vector).

reg rating i.provid i.period i.year_code disclosed_announce, cluster(specialty)

* Estimate effect of disclosure on Rating (include controls vector).

reg rating i.provid i.period i.year_code disclosed_announce charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 4 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate effect of disclosure on Quality Deductions (without controls vector).

reg hac_proc_306090  i.provid i.period i.year_code disclosed_announce, cluster(specialty)

* Estimate effect of disclosure on Quality Deductions (include controls vector).

reg hac_proc_306090  i.provid i.period i.year_code disclosed_announce gender_num charges_num rvus com_index medicare_e week_count age2 age3 age4 age5 age6 age7 age8, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 5 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Time_with_Patient_Data.dta"

* Merge covariates: gender, medicare_exp, rvus, age indicators, com_index, charges_num

merge m:1 unidentifiableid using "/Users/eyring/Documents/DPR Code and Data Sharing Components/Time_with_Patient_Covariates.dta", keep(match master)

**Gender is entered as F or M, recode to 1 or 0 (1=F)

gen gender_num = gender=="F"

**Age indicators are categories outlined by IEA (2020) for health care research.

**age1 = age<5
**age2 = age>4 & age<15
**age3 = age>14 & age<25
**age4 = age>24 & age<35
**age5 = age > 34 & age<45
**age6 = age >44 & age<55 
**age7 = age >54 & age <60 
**age8 = age > 59 

* Generate clinic indicators

tab clinic, gen(clinic_ind)

** Estimate effect of disclosure on Time with Patient (without controls vector).

reg time_with i.period i.provid clinic_ind* i.year_code disclosed_announce, cluster(specialty)

** Estimate effect of disclosure on Time with Patient (include controls vector).

reg time_with i.period i.provid clinic_ind* i.year_code disclosed_announce gender_num charges_num rvus com_ind medicare_exp week_count age2 age3 age4 age5 age6 age7 age8, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 7 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Var_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate effect of disclosure on Absolute Difference (include only sd_per from controls vector).

reg abs_diff i.period i.provid disclosed sd_per, cluster(clinic)

* Estimate effect of disclosure on Absolute Difference (include controls vector).

reg abs_diff i.period i.provid disclosed sd_per charges_num rvus gender medicare_exp firstvis_num week_count early_adol late_adol early_adult middle_adult later_adult old_age eng com_ind, cluster(clinic)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 8 **

* Generate Rating fixed effects for physicians before disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Before_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate physician fixed effects for Rating before disclosure

reg rating i.provid i.year_code charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

* Save results of regression.
regsave using rating_provid_indicators_aft, replace

* Use saved results and keep physician indicators along with coefficients representing physicians' rating fixed effects. 

use rating_provid_indicators_aft, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "99" in 1
destring var1, replace
rename var1 provid
rename coef rating_indicator
keep provid rating_indicator

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Rating_Fixed_Effects_Before.dta", replace


* Generate Rating fixed effects for physicians after disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_After_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate physician fixed effects for Rating after disclosure

reg rating i.provid i.year_code charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

* Save results of regression.
regsave using rating_provid_indicators_aft, replace

* Use saved results and keep physician indicators along with coefficients representing physicians' rating fixed effects. 

use rating_provid_indicators_aft, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "99" in 1
destring var1, replace
rename var1 provid
rename coef rating_indicator
keep provid rating_indicator

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Rating_Fixed_Effects_After.dta", replace


* Generate Quality fixed effects for physicians before disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_Before_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate physician fixed effects for Quality Deductions before disclosure.

reg hac_proc_306090 i.provid i.year_code gender_num charges_num rvus medicare_e week_count com_index age2 age3 age4 age5 age6 age7 age8, cluster(specialty)
regsave using quality_provid_indicators, replace
use quality_provid_indicators, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "974" in 1
destring var1, replace
rename var1 provid
rename coef quality_ind
order provid quality_ind
keep provid quality_ind

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Fixed_Effects_Quality_Before.dta", replace


* Generate Quality fixed effects for physicians after disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_After_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate physician fixed effects for Quality Deductions after disclosure.

reg hac_proc_306090 i.provid i.year_code gender_num charges_num rvus medicare_e week_count com_index age2 age3 age4 age5 age6 age7 age8, cluster(specialty)
regsave using quality_provid_indicators, replace
use quality_provid_indicators, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "974" in 1
destring var1, replace
rename var1 provid
rename coef quality_ind
order provid quality_ind
keep provid quality_ind

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Fixed_Effects_Quality_After.dta", replace


*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 9 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Responses_and_Time_Joint_Data.dta"

* Code indicator for gender as 1 if Female.
gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate pre-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng if before==1, cluster(specialty)

* Estimate post-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng if after==1, cluster(specialty)

* Alternate coding of indicators for age, which is truncated at 89 in the data in compliance with privacy regulations, in categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Estimate pre-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index age2 age3 age3 age5 age6 age7 age8 eng if before==1, cluster(specialty)

* Estimate post-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index age2 age3 age3 age5 age6 age7 age8 eng if after==1, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
*  Disclosing Physician Ratings: Performance Effects and the Difficulty of Altering Ratings Consensus
*
*  Henry Eyring
*
*  Steps and program for main empirical analyses
*  Data are confidential and provided by University of Utah Health Care as described in the attached datasheet
*
********************************************************************************************************************************************


********************************************************************************************************************************************
*
** Table 3 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Data.dta", replace

* Code indicator for gender as 1 if Female.
gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Show coefficients on year dummies alone.

reg rating i.year_code, cluster(specialty)

* Estimate effect of disclosure on Rating (without controls vector).

reg rating i.provid i.period i.year_code disclosed_announce, cluster(specialty)

* Estimate effect of disclosure on Rating (include controls vector).

reg rating i.provid i.period i.year_code disclosed_announce charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 4 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate effect of disclosure on Quality Deductions (without controls vector).

reg hac_proc_306090  i.provid i.period i.year_code disclosed_announce, cluster(specialty)

* Estimate effect of disclosure on Quality Deductions (include controls vector).

reg hac_proc_306090  i.provid i.period i.year_code disclosed_announce gender_num charges_num rvus com_index medicare_e week_count age2 age3 age4 age5 age6 age7 age8, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 5 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Time_with_Patient_Data.dta"

* Merge covariates: gender, medicare_exp, rvus, age indicators, com_index, charges_num

merge m:1 unidentifiableid using "/Users/eyring/Documents/DPR Code and Data Sharing Components/Time_with_Patient_Covariates.dta", keep(match master)

**Gender is entered as F or M, recode to 1 or 0 (1=F)

gen gender_num = gender=="F"

**Age indicators are categories outlined by IEA (2020) for health care research.

**age1 = age<5
**age2 = age>4 & age<15
**age3 = age>14 & age<25
**age4 = age>24 & age<35
**age5 = age > 34 & age<45
**age6 = age >44 & age<55 
**age7 = age >54 & age <60 
**age8 = age > 59 

* Generate clinic indicators

tab clinic, gen(clinic_ind)

** Estimate effect of disclosure on Time with Patient (without controls vector).

reg time_with i.period i.provid clinic_ind* i.year_code disclosed_announce, cluster(specialty)

** Estimate effect of disclosure on Time with Patient (include controls vector).

reg time_with i.period i.provid clinic_ind* i.year_code disclosed_announce gender_num charges_num rvus com_ind medicare_exp week_count age2 age3 age4 age5 age6 age7 age8, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 7 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Var_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate effect of disclosure on Absolute Difference (include only sd_per from controls vector).

reg abs_diff i.period i.provid disclosed sd_per, cluster(clinic)

* Estimate effect of disclosure on Absolute Difference (include controls vector).

reg abs_diff i.period i.provid disclosed sd_per charges_num rvus gender medicare_exp firstvis_num week_count early_adol late_adol early_adult middle_adult later_adult old_age eng com_ind, cluster(clinic)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 8 **

* Generate Rating fixed effects for physicians before disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Before_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate physician fixed effects for Rating before disclosure

reg rating i.provid i.year_code charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

* Save results of regression.
regsave using rating_provid_indicators_aft, replace

* Use saved results and keep physician indicators along with coefficients representing physicians' rating fixed effects. 

use rating_provid_indicators_aft, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "99" in 1
destring var1, replace
rename var1 provid
rename coef rating_indicator
keep provid rating_indicator

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Rating_Fixed_Effects_Before.dta", replace


* Generate Rating fixed effects for physicians after disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_After_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate physician fixed effects for Rating after disclosure

reg rating i.provid i.year_code charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

* Save results of regression.
regsave using rating_provid_indicators_aft, replace

* Use saved results and keep physician indicators along with coefficients representing physicians' rating fixed effects. 

use rating_provid_indicators_aft, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "99" in 1
destring var1, replace
rename var1 provid
rename coef rating_indicator
keep provid rating_indicator

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Rating_Fixed_Effects_After.dta", replace


* Generate Quality fixed effects for physicians before disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_Before_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate physician fixed effects for Quality Deductions before disclosure.

reg hac_proc_306090 i.provid i.year_code gender_num charges_num rvus medicare_e week_count com_index age2 age3 age4 age5 age6 age7 age8, cluster(specialty)
regsave using quality_provid_indicators, replace
use quality_provid_indicators, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "974" in 1
destring var1, replace
rename var1 provid
rename coef quality_ind
order provid quality_ind
keep provid quality_ind

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Fixed_Effects_Quality_Before.dta", replace


* Generate Quality fixed effects for physicians after disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_After_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate physician fixed effects for Quality Deductions after disclosure.

reg hac_proc_306090 i.provid i.year_code gender_num charges_num rvus medicare_e week_count com_index age2 age3 age4 age5 age6 age7 age8, cluster(specialty)
regsave using quality_provid_indicators, replace
use quality_provid_indicators, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "974" in 1
destring var1, replace
rename var1 provid
rename coef quality_ind
order provid quality_ind
keep provid quality_ind

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Fixed_Effects_Quality_After.dta", replace


*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 9 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Responses_and_Time_Joint_Data.dta"

* Code indicator for gender as 1 if Female.
gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate pre-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng if before==1, cluster(specialty)

* Estimate post-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng if after==1, cluster(specialty)

* Alternate coding of indicators for age, which is truncated at 89 in the data in compliance with privacy regulations, in categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Estimate pre-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index age2 age3 age3 age5 age6 age7 age8 eng if before==1, cluster(specialty)

* Estimate post-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index age2 age3 age3 age5 age6 age7 age8 eng if after==1, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
*  Disclosing Physician Ratings: Performance Effects and the Difficulty of Altering Ratings Consensus
*
*  Henry Eyring
*
*  Steps and program for main empirical analyses
*  Data are confidential and provided by University of Utah Health Care as described in the attached datasheet
*
********************************************************************************************************************************************


********************************************************************************************************************************************
*
** Table 3 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Data.dta", replace

* Code indicator for gender as 1 if Female.
gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Show coefficients on year dummies alone.

reg rating i.year_code, cluster(specialty)

* Estimate effect of disclosure on Rating (without controls vector).

reg rating i.provid i.period i.year_code disclosed_announce, cluster(specialty)

* Estimate effect of disclosure on Rating (include controls vector).

reg rating i.provid i.period i.year_code disclosed_announce charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 4 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate effect of disclosure on Quality Deductions (without controls vector).

reg hac_proc_306090  i.provid i.period i.year_code disclosed_announce, cluster(specialty)

* Estimate effect of disclosure on Quality Deductions (include controls vector).

reg hac_proc_306090  i.provid i.period i.year_code disclosed_announce gender_num charges_num rvus com_index medicare_e week_count age2 age3 age4 age5 age6 age7 age8, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 5 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Time_with_Patient_Data.dta"

* Merge covariates: gender, medicare_exp, rvus, age indicators, com_index, charges_num

merge m:1 unidentifiableid using "/Users/eyring/Documents/DPR Code and Data Sharing Components/Time_with_Patient_Covariates.dta", keep(match master)

**Gender is entered as F or M, recode to 1 or 0 (1=F)

gen gender_num = gender=="F"

**Age indicators are categories outlined by IEA (2020) for health care research.

**age1 = age<5
**age2 = age>4 & age<15
**age3 = age>14 & age<25
**age4 = age>24 & age<35
**age5 = age > 34 & age<45
**age6 = age >44 & age<55 
**age7 = age >54 & age <60 
**age8 = age > 59 

* Generate clinic indicators

tab clinic, gen(clinic_ind)

** Estimate effect of disclosure on Time with Patient (without controls vector).

reg time_with i.period i.provid clinic_ind* i.year_code disclosed_announce, cluster(specialty)

** Estimate effect of disclosure on Time with Patient (include controls vector).

reg time_with i.period i.provid clinic_ind* i.year_code disclosed_announce gender_num charges_num rvus com_ind medicare_exp week_count age2 age3 age4 age5 age6 age7 age8, cluster(specialty)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 7 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Var_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate effect of disclosure on Absolute Difference (include only sd_per from controls vector).

reg abs_diff i.period i.provid disclosed sd_per, cluster(clinic)

* Estimate effect of disclosure on Absolute Difference (include controls vector).

reg abs_diff i.period i.provid disclosed sd_per charges_num rvus gender medicare_exp firstvis_num week_count early_adol late_adol early_adult middle_adult later_adult old_age eng com_ind, cluster(clinic)

*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 8 **

* Generate Rating fixed effects for physicians before disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_Before_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate physician fixed effects for Rating before disclosure

reg rating i.provid i.year_code charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

* Save results of regression.
regsave using rating_provid_indicators_aft, replace

* Use saved results and keep physician indicators along with coefficients representing physicians' rating fixed effects. 

use rating_provid_indicators_aft, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "99" in 1
destring var1, replace
rename var1 provid
rename coef rating_indicator
keep provid rating_indicator

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Rating_Fixed_Effects_Before.dta", replace


* Generate Rating fixed effects for physicians after disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Response_After_Data.dta", replace

* Code indicator for gender as 1 if Female.

gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate physician fixed effects for Rating after disclosure

reg rating i.provid i.year_code charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng, cluster(specialty)

* Save results of regression.
regsave using rating_provid_indicators_aft, replace

* Use saved results and keep physician indicators along with coefficients representing physicians' rating fixed effects. 

use rating_provid_indicators_aft, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "99" in 1
destring var1, replace
rename var1 provid
rename coef rating_indicator
keep provid rating_indicator

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Rating_Fixed_Effects_After.dta", replace


* Generate Quality fixed effects for physicians before disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_Before_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate physician fixed effects for Quality Deductions before disclosure.

reg hac_proc_306090 i.provid i.year_code gender_num charges_num rvus medicare_e week_count com_index age2 age3 age4 age5 age6 age7 age8, cluster(specialty)
regsave using quality_provid_indicators, replace
use quality_provid_indicators, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "974" in 1
destring var1, replace
rename var1 provid
rename coef quality_ind
order provid quality_ind
keep provid quality_ind

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Fixed_Effects_Quality_Before.dta", replace


* Generate Quality fixed effects for physicians after disclosure.

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Procedures_After_Data.dta", replace

* Code quality deductions. 

**Note: 
*** hac are hospital acquired conditons, process are deviations from process standards, readmit_30 is readmission occured within 30 days, readmit_60 is readmission occured within 60 days, readmit_90 is readmission within 90 days.
*** readmit_60 is entered as 1 if readmit_30 is 1 (i.e., patient was, by definition, readmitted within 60 days if readmitted within 30 days).
*** readmit 90 is entered as 1 if readmit_60 is 1 (i.e., patient was, by definition, readmitted within 90 days if readmitted within 60 days).
*** Coding for quality deductions below avoids double counting readmissions

gen hac_proc_306090 = hac + process + readmit_30

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_30 == 0 & readmit_60==1

replace hac_proc_306090 = hac_proc_306090 + 1 if readmit_60 == 0 & readmit_90==1

* Code indicator for gender as 1 if Female.

gen gender_num = gender=="F"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (primarypayorcat == "MEDICARE A AND B" | primarypayorcat == "MEDICAID" | primarypayorcat == "MEDICARE PART A" | primarypayorcat == "MEDICARE PART B" | primarypayorcat == "UT MEDICAID")

* Estimate physician fixed effects for Quality Deductions after disclosure.

reg hac_proc_306090 i.provid i.year_code gender_num charges_num rvus medicare_e week_count com_index age2 age3 age4 age5 age6 age7 age8, cluster(specialty)
regsave using quality_provid_indicators, replace
use quality_provid_indicators, clear
keep coef var
split var, p(".")
keep if var2=="provid"
replace var1 = "974" in 1
destring var1, replace
rename var1 provid
rename coef quality_ind
order provid quality_ind
keep provid quality_ind

save "/Users/eyring/Documents/DPR Code and Data Sharing Components/Physician_Fixed_Effects_Quality_After.dta", replace


*
********************************************************************************************************************************************



********************************************************************************************************************************************
*
** Table 9 **

use "/Users/eyring/Documents/DPR Code and Data Sharing Components/Survey_Responses_and_Time_Joint_Data.dta"

* Code indicator for gender as 1 if Female.
gen gender = sex=="Female"

* Code indicators for age, which is truncated at 89 in the data in compliance with privacy regulations. Use age categories as advised by Newman and Newman (2014) to capture changes in psychological function associated with age.

gen early_adol = age>11 & age<18
gen late_adol = age>17 & age<25
gen early_adult = age>24 & age<35
gen middle_adult = age>34 & age<60
gen later_adult = age>59 & age<75
gen old_age = age>74

* Code indicator for payment provided by Medicare or Medicaid.

gen medicare_exp = (modified_pyr == "MEDICARE A AND B" | modified_pyr == "MEDICAID" | modified_pyr == "MEDICARE PART A" | modified_pyr == "MEDICARE PART B" | modified_pyr == "UT MEDICAID")

* Code indicator for visit is patient's first to the physician.

gen firstvis_num = firstvisit=="Yes"

* Code indicator for first language is English.

gen english = itlanguage=="ENG"

* Estimate pre-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng if before==1, cluster(specialty)

* Estimate post-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index early_adol late_adol early_adult middle_adult later_adult old_age eng if after==1, cluster(specialty)

* Alternate coding of indicators for age, which is truncated at 89 in the data in compliance with privacy regulations, in categories as outlined by IEA (2020) for health care research.

gen age1 = age<5
gen age2 = age>4 & age<15
gen age3 = age>14 & age<25
gen age4 = age>24 & age<35
gen age5 = age > 34 & age<45
gen age6 = age >44 & age<55 
gen age7 = age >54 & age <60 
gen age8 = age > 59 

* Estimate pre-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index age2 age3 age3 age5 age6 age7 age8 eng if before==1, cluster(specialty)

* Estimate post-disclosure relationship between Rating and Time with Patient.

reg rating time_with_patient charges_num rvus gender medicare_e firstvis_num week_count com_index age2 age3 age3 age5 age6 age7 age8 eng if after==1, cluster(specialty)

*
********************************************************************************************************************************************




brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 323kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall