Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Weights now allowed
From
Joerg Luedicke <[email protected]>
To
[email protected]
Subject
Re: st: Weights now allowed
Date
Thu, 13 Sep 2012 12:50:19 -0500
You would need to type [`i'] instead of [i] since i is a local macro
here (see -help macro- and -help forvalues-). However, there is no
need to loop over all observations in your data, see -help egen
rowmean-.
J.
On Thu, Sep 13, 2012 at 12:23 PM, Daniel Almar de Sneijder
<[email protected]> wrote:
> Hello Stata
>
> When I attempt to run:
>
> ***** calculates average exp ret age
> drop ravgexpretage
>
> gen double ravgexpretage = r1expretage
>
> forvalues i = 1/30659 {
> replace ravgexpretage[i] = ( r1expretage[i] + r3expretage[i] +
> r4expretage[i] + r5expretage[i] + r6expretage[i] + r7expretage[i] +
> r8expretage[i] )
> replace ravgexpretage[i] = ravgexpretage[i] *(1/7)
> }
>
> I receive the message: "weights not allowed"
>
> What is the problem and How can I circumvene this?
> My initial idea was to add all the variables up and then divide it by
> 7, which works. However it only adds the observations up if each
> variable has a observation So that is why I decided to do it like
> this.
>
> Thanks,
> Daniel
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/