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

st: replace variable, observation by observation

From   "Radu Ban" <>
To   <>
Subject   st: replace variable, observation by observation
Date   Fri, 8 Nov 2002 15:24:25 -0500

Dear all,

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

replace prad_error[`i'] = sqrt(E1`i'[1,1]);

replace constant_coeff[`i'] = C1`i'[1,2];

replace constant_error[`i'] = sqrt(E1`i'[2,2]);

replace nrobs[`i'] = e(N);

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

replace nonzeroobs[`i'] = r(N);

replace regnum[`i'] = `i';

local i = `i' + 1;


when I run it, I get an error message (after the first regression, so I'm
assuming the error is in the loop):

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?

Thanks so much,
Radu Ban

*   For searches and help try:

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