Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Loop


From   Estrella Gomez <[email protected]>
To   [email protected]
Subject   Re: st: Loop
Date   Fri, 19 Apr 2013 10:08:03 +0200

Thanks a lot! Now it works.

Estrella

2013/4/17 Nick Cox <[email protected]>:
> You are correct. Sorry about that.
> Nick
> [email protected]
>
>
> On 17 April 2013 17:59, Jeph Herrin <[email protected]> wrote:
>> I daresay your -if- statement is always true.
>>
>> The poster wants to exclude when x = y, not d`x'=ls`y'. So
>>
>>  if "`x'"!="`y'" {
>>
>>  }
>>
>> J
>>
>>
>>
>> On 4/17/2013 11:50 AM, Nick Cox wrote:
>>>
>>> Same correction as Jeph indicated earlier.
>>>
>>> You want
>>>
>>> if "d`x'" != "ls`y'""
>>> Nick
>>> [email protected]
>>>
>>>
>>> On 17 April 2013 16:07, Estrella Gomez <[email protected]> wrote:
>>>>
>>>> No, it does not work, because Stata does not recognise BE, the name of
>>>> the variable is dBE, but if I say "if d`x' != d`y'", I obtain the same
>>>> error message. I have tried "if d`x' != ls`y'" and "if ls`x' != ls`y'"
>>>> as well, and I obtain the same error
>>>>
>>>>
>>>> 2013/4/17 Jeph Herrin <[email protected]>:
>>>>>
>>>>> foreach x in BE DE ES FR GB US {
>>>>>    foreach y in BE DE ES FR GB US {
>>>>>       if "`x'"!="`y'" {
>>>>>
>>>>>           xi: probit d`x' ls`y' i.d10_comp
>>>>>           outreg2 using
>>>>> "D:\UsersData\Estrella\results\probit_`x'-`y'.xls",
>>>>> bdec(4) se replace
>>>>>       }
>>>>>    }
>>>>> }
>>>>>
>>>>>
>>>>> On 4/17/2013 10:47 AM, Estrella Gomez wrote:
>>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am trying to run 36 probits using this loop:
>>>>>>
>>>>>> foreach x in     BE    DE  ES   FR    GB    US  {
>>>>>> foreach y in BE    DE  ES   FR    GB    US {
>>>>>> xi: probit d`x' ls`y' i.d10_comp
>>>>>> outreg2 using "D:\UsersData\Estrella\results\probit_`x'-`y'.xls",
>>>>>> bdec(4) se replace
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> However, in those cases in which x and y coincides (for instance, xi:
>>>>>> probit dBE lsBE i.d10_comp), I obtain the error message "no
>>>>>> observations".
>>>>>> How could I write this loop for excluding those cases?
>>>>>>
>>>>>> Thank you very much,
>>>>>> Estrella
>>>>>> *
>>>>>> *   For searches and help try:
>>>>>> *   http://www.stata.com/help.cgi?search
>>>>>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index