Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Eric Booth <eric.a.booth@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: -estout- value labels |

Date |
Fri, 20 Apr 2012 15:28:29 -0500 |

<> You could script something to automatically write the varlabels() option of -estout- for you. The example below shows you some ways to do this (it assumes (1) you have properly labeled all your variables _and_ values, and (2) you use the first level of all your categorical vars as the base level) and runs 3 models, changing the varlabels() option each time accordingly. You'd have to do some adapting to your code/data. ********************! watch for wrapping below: clear* sysuse auto, clear **clean up value and variable labels first lab def r 0 "zero" 1 "one" 2 "two" 3 "three" 4 "four" 5 "five" lab val rep78 r //all your factor vars must have value labels **set up models in macros loc iv1 trunk price i.rep78 mpg loc iv2 i.rep78 headr loc iv3 headr mpg i.rep78 trunk turn displacement **base level /*set macro for your base level (assumes same base for all models for simplicity below)*/ loc base = 1 **CREATE ESTOUT FOR ALL YOUR MODELS** forval m = 1/3 { //these are you 3 models loc lab "" **1. make a macro for the varlabels option of estout: foreach v in `iv`m'' { if strpos("`v'", "i.")>0 { //this is for factorvars **this prevents locals from writing on top of itsself from prev. loop loc use "" loc uselab "" loc use = subinstr("`v'", "i.", "", 1) loc uselab `" `:value label `use'' "' levelsof `use', loc(i) foreach j in `i' { //this loops over categorical var levels loc fl "" if `"`base'"' == `"`j'"' loc fl "b" **note: you could make this last line change the base by variable type/name/some other attribute loc lab `"`lab' `j'`fl'.`use' "`: label `uselab' `j'' " "' } //end of j.loop } //end of if *this is for non-factor vars: if strpos("`v'", "i.")<1 { loc lab `"`lab' `v' "`:var lab `v''" "' } } //end of v.loop di `"`lab'"' //check your varlabel() option macro here ** run model quietly regress price `iv`m'' est sto m`m' ** estout estout m`m' using "mymodels`m'.xls", /// replace label /// varlabels(`lab' _cons Intercept) } //end of m.loop ***********! - Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University ebooth@ppri.tamu.edu +979.845.6754 On Apr 20, 2012, at 2:54 PM, Ricardo Ovaldia wrote: > Thank you. Is not hard. Just tedious when you have a lot of models and each with several indicator variables and categorical variables. > > Ricardo Ovaldia, MS > Statistician > Oklahoma City, OK > > > --- On Fri, 4/20/12, Eric Booth <eric.a.booth@gmail.com> wrote: > >> From: Eric Booth <eric.a.booth@gmail.com> >> Subject: Re: st: -estout- value labels >> To: statalist@hsphsun2.harvard.edu >> Date: Friday, April 20, 2012, 2:45 PM >> <> >> >> No. >> Using the xi prefix just changes the background >> labels used from something like "2.rep78" to "_Irep78_2" - >> that seems to me to be the same level of ease/difficulty. >> >> - Eric >> >> __ >> Eric A. Booth >> Public Policy Research Institute >> Texas A&M University >> ebooth@ppri.tamu.edu >> +979.845.6754 >> >> >> On Apr 20, 2012, at 2:35 PM, Ricardo Ovaldia wrote: >> >>> Thank you Eric. Will the task be any easier if I use >> -xi- instead of factor variables? >>> >>> Ricardo >>> >>> Ricardo Ovaldia, MS >>> Statistician >>> Oklahoma City, OK >>> >>> >>> --- On Fri, 4/20/12, Eric Booth <eric.a.booth@gmail.com> >> wrote: >>> >>>> From: Eric Booth <eric.a.booth@gmail.com> >>>> Subject: Re: st: -estout- value labels >>>> To: statalist@hsphsun2.harvard.edu >>>> Date: Friday, April 20, 2012, 12:53 PM >>>> <> >>>> >>>> >>>> I assume the issue is with using factor variables >> in a model >>>> (-help help fvvarlist-) that you are exporting via >>>> -estout-? >>>> Use the 'varlabels' option already built into >> -estout- (see >>>> -help estout-). Also -estout- is from SSC. >>>> >>>> >>>> Example: >>>> >>>> *************! >>>> clear* >>>> sysuse auto, clear >>>> eststo, title("M1"): quietly regress price rep78 >> mpg >>>> eststo, title("M2"): quietly regress price i.rep78 >> mpg >>>> ** >>>> estout * using "test.xls", /// >>>> replace label /// >>>> varlabels(rep78 "rep78 test" mpg "mpg test label" >> 1b.rep78 >>>> "1st level" 2.rep78 "2nd level" 3.rep78 "3rd l" >> 4.rep78 >>>> "4th" 5.rep78 "5th level of >> rep78" _cons >>>> Intercept) >>>> >>>> **************! >>>> >>>> - Eric >>>> >>>> __ >>>> Eric A. Booth >>>> Public Policy Research Institute >>>> Texas A&M University >>>> ebooth@ppri.tamu.edu >>>> +979.845.6754 >>>> >>>> >>>> On Apr 20, 2012, at 11:23 AM, Ricardo Ovaldia >> wrote: >>>> >>>>> Hello, >>>>> >>>>> Is there a way to display value labels for >> categorical >>>> variables using -estout-? I can do it wit >> -reformat- , but >>>> can not figure how to do it with -estout-. >>>>> >>>>> Thank you, >>>>> Ricardo >>>>> >>>>> Ricardo Ovaldia, MS >>>>> Statistician >>>>> Oklahoma City, OK >>>>> * >>>>> * 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/ >>>> >>> >>> * >>> * 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/ >> > > * > * 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/

**References**:**Re: st: -estout- value labels***From:*Ricardo Ovaldia <ovaldia@yahoo.com>

- Prev by Date:
**Re: st: correction for within panel serial correlation in standard errors** - Next by Date:
**st: Random sample panel data** - Previous by thread:
**Re: st: -estout- value labels** - Next by thread:
**st: question concerning mlsum for ml with panel-data** - Index(es):