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

Re: st: tricky calculation with dozens of variables


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: tricky calculation with dozens of variables
Date   Sun, 9 Oct 2005 08:00:12 -0400

You have the quotes wrong in referencing i. It should be `i', not 'i'. You will also need to generate total=0 to start.

Michael Blasnik
[email protected]

----- Original Message ----- From: "Jia Xiangping" <[email protected]>
To: <[email protected]>
Sent: Sunday, October 09, 2005 5:04 AM
Subject: Re: st: tricky calculation with dozens of variables



Hi Svend,

It still doesn't work. I programed in this way(variables name are
different in my dataset, so I still use you example for convenience)

//calculated total
forvalues i=4(11)386{
local j='i'+4
replace total=total+var'i'*var'j'
}

Then Stata 8.2 informs me
'i' invalid name
r(198)

If I need to define i before run the ado above? Thanks

Joe
*
*   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