Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: replace variable, observation by observation


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: replace variable, observation by observation
Date   Mon, 11 Nov 2002 09:24:21 -0000

I wrote 

> 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; 
thus 

. 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-. 
 
Nick 
[email protected] 
 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index