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

st: RE: replace variable, observation by observation

From   "Jiang, Tao" <>
To   "''" <>
Subject   st: RE: replace variable, observation by observation
Date   Fri, 8 Nov 2002 15:19:56 -0500

if prad_coeff is variable, use:

replace prad_coeff = C1`i'[1,1] in `i'

dp similar changes for others.

-----Original Message-----
From: Radu Ban []
Sent: Friday, November 08, 2002 3:24 PM
Subject: st: replace variable, observation by observation 

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:
*   For searches and help try:

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