******************************************************************************* *Paper Title: Practice Specialization and Post-acute Outcomes of Patients with *Dementia in Skilled Nursing Facilities ******************************************************************************* ******************************************************************************* *(1) Create Group 1 ******************************************************************************* *clean propensity score 2012* clear use "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/pscore_2012_12_20_23.dta" keep EPISODE_ID p_SL_full rename p_SL_full p_SL_full_12 save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/pscore_2012_subset.dta", replace *clean propensity score 2019* clear use "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/pscore_2019_12_20_23.dta" keep EPISODE_ID p_SL_full rename p_SL_full p_SL_full_19 save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/pscore_2019_subset.dta", replace *merge both p_scores to main data*/ use "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/matching_1219_12_20_23.dta" drop _merge merge 1:1 EPISODE_ID using "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/pscore_2012_subset.dta" drop _merge merge 1:1 EPISODE_ID using "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/pscore_2019_subset.dta" drop _merge save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group1_12_20_23.dta", replace *Pscore matching clear use "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group1_12_20_23.dta" *Only keep patients seen by SNFist and find patietns who saw a SNFist in 2019 and would have seen a SNFist in 2012 as well keep if SNFIST_METHOD2_80==1 gen treat=0 replace treat=1 if SNF_ADMIT_YEAR==2012 *Calcualte standard deviation for caliper sum p_SL_full_12 scalar cal = r(sd)*0.1 *randomize order before matching set seed 12345 tempvar sortorder gen `sortorder' = runiform() sort `sortorder' *Propensity score matching - within cluster *Generate variables that are needed for propensity score matching gen weight =. gen pscore =. gen treated =. gen support =. gen id =. gen n1=. gen nn=. gen pdif=. egen c = group(PRVDR_NUM) levels c, local(cluster) quietly foreach j of local cluster { psmatch2 treat if c==`j', pscore(p_SL_full_12) caliper(`=scalar(cal)') neighbor(1) common replace weight = _weight if c==`j' replace pscore = _pscore if c==`j' replace treated = _treated if c==`j' replace support = _support if c==`j' replace id = _id if c==`j' replace n1 = _n1 if c==`j' replace nn= _nn if c==`j' replace pdif=_pdif if c==`j' } save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group1_after_match_12_20_23.dta", replace replace _weight = weight replace _pscore = pscore replace _treated = treated replace _support = support replace _id = id replace _n1 = n1 replace _nn = nn replace _pdif=pdif save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group1_after_match_12_20_23.dta", replace ************************************************************* *(2) Create Group 2 ******************************************************************************* *Save not matched* clear use "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group1_after_match_12_20_23.dta" keep if weight==. keep if SNF_ADMIT_YEAR==2019 save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/SNFist19_and_not_matched_12_20_23", replace *Identify those that didn't see SNFist in 2012 clear use "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group1_12_20_23.dta" keep if SNF_ADMIT_YEAR==2012 & SNFIST_METHOD2_80==0 append using "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/SNFist19_and_not_matched_12_20_23" drop weight pscore treated support id n1 nn pdif drop treat gen treat=0 replace treat=1 if SNF_ADMIT_YEAR==2019 sum p_SL_full_19 scalar cal = r(sd)*0.1 *randomize order before matching set seed 12345 tempvar sortorder gen `sortorder' = runiform() sort `sortorder' *Propensity score matching - within cluster gen weight =. gen pscore =. gen treated =. gen support =. gen id =. gen n1=. gen nn=. gen pdif=. drop c egen c = group(PRVDR_NUM) levels c, local(cluster) quietly foreach j of local cluster { psmatch2 treat if c==`j', pscore(p_SL_full_19) caliper(`=scalar(cal)') neighbor(1) common replace weight = _weight if c==`j' replace pscore = _pscore if c==`j' replace treated = _treated if c==`j' replace support = _support if c==`j' replace id = _id if c==`j' replace n1 = _n1 if c==`j' replace nn= _nn if c==`j' replace pdif=_pdif if c==`j' } save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group2_after_match_12_20_23.dta", replace replace _weight = weight replace _pscore = pscore replace _treated = treated replace _support = support replace _id = id replace _n1 = n1 replace _nn = nn replace _pdif=pdif save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group2_after_match_12_20_23.dta", replace ************************************************************* *(1) Create Group 3 ************************************************************* *Identify those that didn't see SNFist in 2012 and 2019 clear use "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group1_12_20_23.dta" keep if SNFIST_METHOD2_80==0 gen treat=0 replace treat=1 if SNF_ADMIT_YEAR==2019 sum p_SL_full_19 scalar cal = r(sd)*0.1 *randomize order before matching set seed 12345 tempvar sortorder gen `sortorder' = runiform() sort `sortorder' *Propensity score matching - within cluster gen weight =. gen pscore =. gen treated =. gen support =. gen id =. gen n1=. gen nn=. gen pdif=. egen c = group(PRVDR_NUM) levels c, local(cluster) quietly foreach j of local cluster { psmatch2 treat if c==`j', pscore(p_SL_full_19) caliper(`=scalar(cal)') neighbor(1) common replace weight = _weight if c==`j' replace pscore = _pscore if c==`j' replace treated = _treated if c==`j' replace support = _support if c==`j' replace id = _id if c==`j' replace n1 = _n1 if c==`j' replace nn= _nn if c==`j' replace pdif=_pdif if c==`j' } save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group3_after_match_12_20_23.dta", replace replace _weight = weight replace _pscore = pscore replace _treated = treated replace _support = support replace _id = id replace _n1 = n1 replace _nn = nn replace _pdif=pdif save "/project/Ryskina_SNFists/Seiyoun_working/ADRD/Stata_code_and_data/group3_after_match_12_20_23.dta", replace