Announcement

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

  • Odd "too many weights r(198)" error

    I have a dataset with ~120,000 students nested in about 6,000 schools. It contains school-level weights (coded as doubles) and a variable called PUBLIC (dichotomous indicator variable) that varies only at the school level. I run the following code:

    Code:
    bysort sch_id: gen sch_row = _n
    tabstat PUBLIC if sch_row = 1 [aw=sch_weight]
    The first line uniquely identifies each within-school row, and the "if" condition in the second line is intended to restrict -tabstat- to one row per school.

    I get the "too many weights" error when I run the above lines. However, if I do the following, it works:

    Code:
    keep if sch_row = 1
    tabstat PUBLIC [aw=sch_weight]
    As far as I can tell, the second is doing the same thing that the first should be doing (i.e., identical data), but the first returns an error and the second doesn't. Obviously, I can work around the error, but it's annoying, and in the future it could mean a lot of preserves/restores that would greatly impact performance. Does anyone know why this is happening?

    Darrick

  • #2
    The error message you are getting is, unfortunately, misleading. It has nothing to do with your weights:

    Code:
    tabstat PUBLIC if sch_row = 1 [aw=sch_weight]
    is illegal syntax because you need to use the double-equals (==) equality relationship operator, not the single-equals (=) replacement operator. The parser somehow just got confused in this context. It was basically off the path once it hit that =, and I suppose in trying to recover by doing a little look-ahead to see what might be wrong, it got misled by the weights into thinking it was seeing something completely different from your intent.


    Comment


    • #3
      Good god, what a rookie mistake. Thank you!

      Comment

      Working...
      X