Bookmark and Share

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: Loop-within-loop error while looping over observations for a microsimulation


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Loop-within-loop error while looping over observations for a microsimulation
Date   Mon, 6 Aug 2012 16:59:23 +0100

No "seems to indicate" here: simply, subscripts are not allowed to the
left of the assignment in Stata.

The syntax diagram shows the form -replace oldvar = exp-. Stuff can
follow that, but nothing else can be included.

Nick

On Mon, Aug 6, 2012 at 4:53 PM, Stephen Cranney
<[email protected]> wrote:
> Thanks for catching that; it's still giving me the "weights not
> allowed" error message though, even when I delete the extra space.
>
> I found this prior Statlist post that seems to indicate that Stata
> triggers the no weights allowed warning when the `i' is placed to the
> left of the equals sign:
>
> http://www.stata.com/statalist/archive/2006-08/msg00976.html
>
> So I changed my code to the following, but I'm still getting the "no
> weights allowed" message.
>
> local N = _N
> forvalues i = 1/`N' {
>         forvalues j= 0/12 {
>                 replace childbirth= rbinomial(1, probabilityconceive) if childbirth== .f
>                 replace childbirth[_n+j]== .i if (childbirth==1) in `i'
>                 }
>         }
>
> Best,
>
>
>
> On Mon, Aug 6, 2012 at 9:32 AM, daniel klein
> <[email protected]> wrote:
>> I did not follow closely, but there is a space between <childbirth>
>> and  <[`i']> in your code, probably causing Stata to interpret <[`i']>
>> as some kind of weight, rather than a subscript.
>>
>> Best
>> Daniel
>>
>> --
>> [...]
>> However, when I change the
>> monthsofpostpartum variable to a constant (in this case 12), it's
>> giving me a "weights not allowed" sign.
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index