Statalist


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

How to run loops with outreg (was st: How to regress and outreg byyear?)


From   Roy Wada <roywada@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   How to run loops with outreg (was st: How to regress and outreg byyear?)
Date   Wed, 14 May 2008 11:04:39 -0700

Here's a template on running loops with outreg:

* data setup
cd d:\
sysuse auto, clear
gen id=0
replace id=1 in 16/45
ren foreign year
levelsof year

* the relevant part
foreach var in `r(levels)' {
     xi: areg price mpg turn i.rep if year==`var', absorb(id)
     outreg using myfiles, `append'
     local append "append" 
}


Here's the original solution:

http://www.stata.com/statalist/archive/2004-06/msg00231.html



>Dear all,
>
>May I ask a novice question? I'm really new to Stata. I want to run regression 
>by year and the outreg the coefficients for each year. I want to use like :
>by year: xi: areg score age education , absorb(nation), but stata tells me "by" 
>can not be combined with xi. Anyone has good solutions? Also I don't think 
>using by can outreg coefficients for each year.
>
>Many thanks in advance!
>
>Best,
>
>Martin

_________________________________________________________________
Get Free (PRODUCT) RED™  Emoticons, Winks and Display Pics.
http://joinred.spaces.live.com?ocid=TXT_HMTG_prodredemoticons_052008
*
*   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/



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