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: foreach command


From   Ronan Conroy <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: foreach command
Date   Tue, 22 May 2012 17:59:59 +0100

On 2012 Beal 22, at 17:13, Caliph Omar Moumin wrote:

> I wanted to regress a data with many categories so i used this command
>  by subchapter2, sort: xtreg cost duration sex agegroup group, re robust
>  
> the problem is this command does not accept xi: command to change the var 'agegroup' into dummy variable
>  
> then i try to use foreach command, and i appplied it like this
>  foreach subchapter2_value in 1 2 3 4 5 6 7 8 9 10 11 {
> xi: xtreg cost duration sex i.agegroup group if subchapter2== `subchapter2_value', re robust
> }
>  
>  
> Now the problem is i cannot see the label name in the later case

This is a nuisance. The solution I adopt is

foreach subchapter2_value in 1 2 3 4 5 6 7 8 9 10 11 {
di "*================================================*"
di "* Results for Subchapter `subchapter2_value'     *
di "*================================================*"
di
di
xi: xtreg cost duration sex i.agegroup group if subchapter2== `subchapter2_value', re robust
}
 
This prints an old-fashioned ASCII banner in the output. However, I miss the option to echo the command during execution, as happened with the now-deprecated -for-

Ronán Conroy
[email protected]
Associate Professor
Division of Population Health Sciences
Royal College of Surgeons in Ireland
Beaux Lane House
Dublin 2


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index