Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • invalid name

    i want to run this but i received "/invalid name" what should i revise?
    use `el_data', clear

    * Covariates
    local indiv age_bl age_miss gender_bl rec_level_idi_bl //individual covariates
    local sch_level student_teacher_ratio overage_ece_num school_year //school level covariates

    * Specifications for subgroup analysis
    local conditions "`"if !missing(rec_level_idi_bl)"' `"if rec_level_idi_bl == 1"' `"if (rec_level_idi_bl == 2 | rec_level_idi_bl == 3)"' `"if gender_el == 0"' `"if gender_el == 1"'"

    * Set up table variables
    gen Condition = ""
    gen Control = .
    gen ITT = .
    gen ITT_pval = .
    gen TrInt = .
    gen TrInt_pval = .
    local i 1

    *Loop over conditions for subgroup analysis
    foreach condition in `conditions'{

    * Condition
    replace Condition = "`condition'" in `i'

    * Control
    sum rec_level_idi_el `condition' & treatment_el == 0
    replace Control = `r(mean)' in `i'

    * ITT
    reg rec_level_idi_el treatment_el `indiv' `sch_level' i.pca_strata `condition', cluster(school_id)
    mat results = r(table)
    replace ITT = results[1,1] in `i'
    replace ITT_pval = results[4,1] in `i'

    * TOT
    ivregress 2sls rec_level_idi_el (treatment_intensity = treatment_el) `indiv' `sch_level' i.pca_strata `condition', vce(cluster school_id)
    mat results = r(table)
    replace TrInt = results[1,1] in `i'
    replace TrInt_pval = results[4,1] in `i'

    local ++i
    }

  • #2
    After

    Code:
    local indiv age_bl age_miss gender_bl rec_level_idi_bl //individual covariates
    the text

    Code:
    // individual covariates
    is included as part of the local macro's contents. So, as soon as you start using that macro for real, a command has to work out what the first / means, and it fails.

    So take out that text, which you intended as comment, and put it somewhere else, e.g. on a line by itself.

    Two debugging tips for anyone:

    1. The problem is that Stata can't make sense of the slash, so where did that come from? Answer: the first command.

    2. Use set trace and show people where the command failed.

    Comment


    • #3
      thank you so much!

      Comment

      Working...
      X