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

From |
Ernest Berkhout <ernestb@seo.fee.uva.nl> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Help: typo-error in for-loop or more serious problem?? |

Date |
Mon, 24 Feb 2003 15:28:01 +0100 |

Hi all, i was looking for a way to cycle through all the values of a particular variable 'oplnr' without having to hardcode these values (they changes every year). Walking through some faqs I come across the program 'vallist' which should be able to do this for me. I integrated this in a small foreach-loop program, but I get an errormessage that does not make sense to me. As I'm not very experienced in programming Stata, it might be some silly typo which I overlooked, but I cant see what is is. Or is there maybe some other problem unknown to me? The basic idea is to create a set of dummy-variables for interactions between to variables oplnr & brinnr. But not all combinations are meaningful in practice, so for reason of efficiency I want to drop all dummies that indicate 'empty cells', that is for which all records have a zero-value. The program stores the values of a variable 'oplnr' in some macro `oplnr', and then I introduce another loop which should cycle through a second set of values (1 to 13) stored in the macro `brinnr'. The following is the code that I've written: ****************************** gen temp=. vallist oplnr foreach oplnr of local r(list) { forvalues brinnr = 1/13 { gen byte opXbr_`oplnr'_`brinnr' = (oplnr==`oplnr' & brinkort==`brinnr') qui summ opXbr_`oplnr'_`brinnr', meanonly replace temp=r(max) if temp==0 drop opXbr_`oplnr'_`brinnr' } } drop temp ******************************************** The error message I get is: { required r(100) Can someone please hint me what is wrong in my code? I do have 2 opening and 2 closing brackets, why does that produce such an error? Ernest Berkhout Stichting voor Economisch Onderzoek Universiteit van Amsterdam De SEO is verhuisd! Tegenwoordig ben ik bereikbaar op: Kamer 3.08 Roetersstraat 29 1018 WB Amsterdam tel.:+ 31 20 525 1630 fax:+ 31 20 525 1686 http://www.seo.nl ================================= "To an economist, real life is a special case" ================================= * * 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**:**st: RE: Help: typo-error in for-loop or more serious problem??***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: RE: Help: typo-error in for-loop or more serious problem??***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: Re: double-hurdle models (Was: some help)** - Next by Date:
**RE: st: OS X 10.2.4 & Stata 8/SE crash confirm?** - Previous by thread:
**Re: st: Re: stcurve - help** - Next by thread:
**st: RE: Help: typo-error in for-loop or more serious problem??** - Index(es):

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