program gen_interaction
    * Define indicator labels
    local label_B_0 "No bonus"
    local label_B_1 "Bonus"
    local label_L_0 "No limit"
    local label_L_1 "Limit"
    local label_B_L_0_0 "No bonus x No limit"
    local label_B_L_0_1 "No bonus x Limit"
    local label_B_L_1_0 "Bonus x No limit"
    local label_B_L_1_1 "Bonus x Limit"

    * Create variable-specific limit x bonus indicators
    cap drop LimitIndicator
    cap drop B_*
    cap drop L_*

    gen LimitIndicator = (S2_LimitType != 0)
    xi, noomit i.S3_Bonus*i.LimitIndicator
    rename _IS3_Bonus_* B_*
    rename _ILimitIndi_* L_*
    rename _IS3_XLim_* B_L_*

    * Label indicators
    foreach v of varlist B_* L_* {
        label var `v' "`label_`v''"
    }
end

exit