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   Sun, 10 Nov 2002 17:04:54 -0000

Radu Ban 
> 
> I have the following loop (this is only a part of a do file)
> .....
> 
> for any prad_coeff prad_error prad_tval constant_coeff 
> constant_error
> constant_tval nrobs nonzeroobs regnum: gen X = 999;
> 
> local i = 1;
> 
> foreach var of varlist `outcomes' {;
> 
> reg `var' prad;
> 
> mat C1`i' = e(b);
> 
> mat E1`i' = e(V);
> 
> replace prad_coeff[`i'] = C1`i'[1,1];

< snip > 
> 
> replace count if `var' ~= 0 & `var' ~= .;
> 

< snip> 
> 
> weights not allowed
> 
> I'm not sure what this means, but I suspect that I cannot 
> replace variables
> observation by observation. Is there a way to work around this?
> 

As Tao Jiang wrote 
 
> if prad_coeff is variable, use:
> 
> replace prad_coeff = C1`i'[1,1] in `i'
> 
> dp similar changes for others.

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. 

Your -replace count- will fail, in the 
absence of an expression. 


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