[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
nicola.baldini2@unibo.it |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: looping from 1 to a number defined by a scalar |

Date |
Mon, 24 Dec 2007 18:15:00 +0100 |

I would like to create a loop from 1 to a number defined by a scalar, but: . forvalues 1/ng { 2. mat p=inv((r1+vu)/ns[`i'])*r1 3. mat q=r2*(idd-p) 4. mat xtilde`i' = xmean*p +mux3*(idd-p)+dz*q 5. } invalid syntax r(198); However, ng = 63 so that the following works: . forvalues 1/63 { 2. mat p=inv((r1+vu)/ns[`i'])*r1 3. mat q=r2*(idd-p) 4. mat xtilde`i' = xmean*p +mux3*(idd-p)+dz*q 5. } Anything shorter than...? local i = 0 while `i' < ng { 2. local i = `i' + 1 3. mat p=inv((r1+vu)/ns[`i'])*r1 4. mat q=r2*(idd-p) 5. mat xtilde`i' = xmean*p +mux3*(idd-p)+dz*q 6. } Merry Xmas, Nicola * * 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/

**Follow-Ups**:**Re: st: looping from 1 to a number defined by a scalar***From:*"Tom Trikalinos" <ttrikalin@gmail.com>

- Prev by Date:
**st: re: time variable with gaps** - Next by Date:
**st: error 198 in outreg2 with option beta** - Previous by thread:
**st: re: time variable with gaps** - Next by thread:
**Re: st: looping from 1 to a number defined by a scalar** - Index(es):

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