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

From |
"Friedrich Huebler" <fhuebler@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Loop over variables with svyset |

Date |
Wed, 19 Nov 2008 13:48:55 -0500 |

Daniel, First, you don't say which error you encounter. Please elaborate. Second, you can include a -di- command in your loop to check if the values of k are the values you need. capture { forvalues k=1/3 { if `k' < 100 local k 0`k' if `k' < 10 local k 0`k' di "k = `k'" etc. Friedrich On Wed, Nov 19, 2008 at 12:57 PM, Daniel Schultz <schultzd@tcd.ie> wrote: > Ok thanks for all the comments... > with the -capture block the do-file is running, > BUT > is actually producing no output after the first error. > This is the part of my do-file (to make it more quick only until Number 3) > > capture { > forvalues k=1/3{ > if `k' < 100 local k 0`k' > if `k' < 10 local k 0`k' > forvalues year=2/7 { > svyset [pw=Q1170_0`year'] > svy: tab Q0`k'_0`year' > mat Q0`k'_0`year' = (e(Prop)\e(total)) > } > } > } > > The first error occurs after the first run of the second forvalues > (forvalues year=2/7 {) loop (number 3). > With the capture block, the do-file is working, but the mat command > only produces a matrix until the first error (a matrix only for year > =2). Thus, I assume, that it is not working totally. > > With adding -noisily the do file stops when the first error occurs. > Best > Daniel > > > 2008/11/19 Buzz Burhans <buzzb3@verizon.net>: >> server >> >> Steve wrote >> "Just be aware that captured statements, whether they produce errors >> or not, show no output." >> >> >> -capture noisily { >> ... >> }- >> >> will produce output if the command does not fail and would otherwise produce >> output. >> >> So capture, with noisily added, should give you output, unless the command >> fails >> >> Buzz Burhans * * 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**:**Re: st: Loop over variables with svyset***From:*"Daniel Schultz" <schultzd@tcd.ie>

**References**:**Re: st: Loop over variables with svyset***From:*Steven Samuels <sjhsamuels@earthlink.net>

**RE: st: Loop over variables with svyset***From:*"Buzz Burhans" <buzzb3@verizon.net>

**Re: st: Loop over variables with svyset***From:*"Daniel Schultz" <schultzd@tcd.ie>

- Prev by Date:
**RE: st: RE: execute external program from within Stata?** - Next by Date:
**Re: st: esttab question** - Previous by thread:
**Re: st: Loop over variables with svyset** - Next by thread:
**Re: st: Loop over variables with svyset** - Index(es):

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