| | cap program drop create_median |
| |
|
| | capture { |
| | program create_median |
| | syntax, var(str) prefix(str) |
| | |
| | sum `var', detail |
| | local med = r(p50) |
| | |
| | cap drop `prefix'_Indicator |
| | gen `prefix'_Indicator = . |
| | replace `prefix'_Indicator = 0 if `var' < `med' |
| | replace `prefix'_Indicator = 1 if `var' >= `med' |
| | end |
| | } |
| |
|
| | |
| | local G0 "if S0_Gender == 1" |
| | local G1 "if S0_Gender == 2" |
| | |
| | create_median, var(S1_Income) prefix("MI") |
| | create_median, var(S1_Education) prefix("ME") |
| | create_median, var(S0_Age) prefix("MA") |
| | create_median, var(StratWantRestrictionIndex) prefix("MR") |
| | create_median, var(StratAddictionLifeIndex) prefix("ML") |
| | create_median, var(PD_P1_UsageFITSBY) prefix("MU") |
| |
|
| | local I0 "if MI_Indicator == 0" |
| | local I1 "if MI_Indicator == 1" |
| | local E0 "if ME_Indicator == 0" |
| | local E1 "if ME_Indicator == 1" |
| | local A0 "if MA_Indicator == 0" |
| | local A1 "if MA_Indicator == 1" |
| | local U0 "if MU_Indicator == 0" |
| | local U1 "if MU_Indicator == 1" |
| | local R0 "if MR_Indicator == 0" |
| | local R1 "if MR_Indicator == 1" |
| | local L0 "if ML_Indicator == 0" |
| | local L1 "if ML_Indicator == 1" |
| |
|
| | |
| | local label_G0 "Male" |
| | local label_G1 "Female" |
| |
|
| | local label_I0 "Below median income" |
| | local label_I1 "Above median income" |
| | local label_E0 "Below median education" |
| | local label_E1 "Above median education" |
| | local label_A0 "Below median age" |
| | local label_A1 "Above median age" |
| | local label_U0 "Below median period 1 usage" |
| | local label_U1 "Above median period 1 usage" |
| | local label_R0 "Below median restriction index" |
| | local label_R1 "Above median restriction index" |
| | local label_L0 "Below median addiction index" |
| | local label_L1 "Above median addiction index" |
| |
|
| | local suffix_I "income" |
| | local suffix_E "educ" |
| | local suffix_A "age" |
| | local suffix_G "gender" |
| | local suffix_U "usage" |
| | local suffix_R "restrict" |
| | local suffix_L "life" |
| |
|