[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: STATA loop terminating over missing variables |

Date |
Mon, 1 Dec 2008 14:15:07 -0000 |

The original question seems backwards. The purpose of the loop as written is to create (e.g.) mindiff1_2 from mindiff1 and mindiff_2, so that far from being a problem, the prior non-existence of mindiff1_2 is expected. Perhaps the questioner meant that some of the mindiff1-mindiff15 may not exist, in which case a better syntax is (as indicated by Maarten) forval i = 1/15 { forval j = 1/15 { capture gen mindiff`i'_`j' = mindiff`i' - mindiff`j' } } Note correction of typo ``i' to `i'. Nick n.j.cox@durham.ac.uk Maarten buis --- Akshay SHanker <ashanker@optusnet.com.au> wrote: > I am running the following simple loop which i need some help with: > > forvalues i =1/15 { > forvalues j=1/15{ > gen mindiff`i'_`j' = mindiff``i' - mindiff`j' > } > } > > The problem is that not all combinations of i and j exist , so for > example mindiff1_2 may not exist. Everytime the loop goes over such a > variable, the loop terminates and thus stops running the loop over > all consecutive variables which may exist. How do i stop the loop > from terminating? see: -help capture- * * 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/

**Follow-Ups**:**st: About stochastic dominance analysis??***From:*Jeetendra Aryal <jeetendra.aryal@umb.no>

**References**:**st: STATA loop terminating over missing variables***From:*Akshay SHanker <ashanker@optusnet.com.au>

**Re: st: STATA loop terminating over missing variables***From:*Maarten buis <maartenbuis@yahoo.co.uk>

- Prev by Date:
**Re: st: re: memory allocation problem** - Next by Date:
**Re: st: RE: nbreg proc genmod equivalency** - Previous by thread:
**Re: st: STATA loop terminating over missing variables** - Next by thread:
**st: About stochastic dominance analysis??** - Index(es):

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