Statalist


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

Re: st: Loop over variables with svyset


From   "Daniel Schultz" <[email protected]>
To   [email protected]
Subject   Re: st: Loop over variables with svyset
Date   Fri, 21 Nov 2008 11:35:34 +0000

Sorry for not mention the error.
I thought that the error message is clear, due to my description.
The error message is, that a variable is not found. This is due to the
fact, that I don't have every variable for every year. Which is the
reason why I need a loop like the one Steven posted. But which shows
respect to the fact, that some variables are missing. (concerning the
year).

Hope this was explanation enough.

2008/11/19 Friedrich Huebler <[email protected]>:
> 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 <[email protected]> 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 <[email protected]>:
>>> 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/
>
>
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index