[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: RE: replace variable, observation by observation
> The error message arises because
> Stata guesses that you are trying to specify weights
> and weights, specified in [ ], are not allowed on the LHS of
> a -replace- statement. It is also true that subscripts
> specified in  are not allowed on the LHS of a -replace-
> statement, but then they are not allowed in any Stata statement
> that I can think of.
I should correct and expand on this.
You can use _matrix_ subscripts on the LHS (left-hand side)
of a command like
matrix whatever[1,1] = 234
but I cannot recall an instance in which you can
use subscripts indicating observations on the
LHS of a non-matrix assignment.
When specifying weights it is in fact legal
to write them hard against a variable name;
. su mpg[w=headroom]
is legal. There could be a little discussion
about whether (1) allowing this was a good idea
(2) doing this is good style, but set those
issues aside: this is legal, and it helps to
explain why Stata misreads illegal subscripts
as illegal attempts to assign weights
in a -replace-.
* For searches and help try: