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   Jia Xiangping <[email protected]>
To   [email protected]
Subject   Re: st: tricky calculation with dozens of variables
Date   Mon, 10 Oct 2005 02:12:14 +0800

Dear all,

The program Svend gave before is total right. I made quotas mistake
when I coded the loop.

In order to show my graditude and respect to Svend and Michael
Blasnik, I made a tiny change on the pragram and it is equivalent to
Svend's.

gen total=0
forvalues i=4 15: 386
local j=`i'+4
replace expens3=expens+var`i'*var`j'
}

Thanks a lot..



On 10/9/05, Svend Juul <[email protected]> wrote:
> Joe,
>
> You wrote:
>
> //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)
>
> Your problem is the single quotes. The left single quote is ` (grave).
> It may be on the upper left corner of your keyboard, or it may be
> elsewhere. It may also be a dead key, displaying nothing until you hit
> the spacebar.
>
> The Stata manuals are not very explicit on this, and you are not the
> first who had this difficulty.
>
> Svend
>
> ________________________________________________________
>
>
> Svend Juul
> Institut for Folkesundhed, Afdeling for Epidemiologi
> (Institute of Public Health, Department of Epidemiology)
> Vennelyst Boulevard 6
> DK-8000 Aarhus C,  Denmark
> Phone, work:  +45 8942 6090
> Phone, home:  +45 8693 7796
> Fax:          +45 8613 1580
> E-mail:       [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/
>


--
Xiangping JIA

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