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: Output format after 'margins'
From
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: Output format after 'margins'
Date
Mon, 19 Nov 2012 16:10:31 +0100
On Mon, Nov 19, 2012 at 3:35 PM, Pham Ngoc Minh wrote:
> I often encounter calculation of adjusted means or ORs using
> 'margins', but don't know how to control the format of outputs, i.e.,
> decimal numbers to present data in tables quickly. I have to do this
> work manually by copying data to excel for manipulation, but it is
> time-consuming. Does anyone have suggestions to make the work faster?
You can use the -post- option in -margins- to make it return its
results as if it is an estimation command. This allows you to use
several user-written programs for displaying and exporting such
models. I like -estout-, mainly because of the extremely extensive set
of examples available at <http://repec.org/bocode/e/estout/>, but
there are others. You can install -estout- by typing in Stata -ssc
install estout-.
*--------------------- begin example ----------------------
// data preparation
sysuse nlsw88, clear
gen byte goodjob = occupation < 3 if occupation < .
label variable goodjob `"respondent has a "good job""'
label define goodjob 1 "profesional or manegerial" ///
0 "other"
label value goodjob goodjob
gen byte marst = !never_married + married ///
if !missing(never_married, married)
label variable marst "marital status"
label define marst 0 "never married" ///
1 "divorced or widowed" ///
2 "married"
label value marst marst
gen byte black = race == 2 if race < 3
label variable black "race"
label define black 0 "white" ///
1 "black"
label value black black
// estimate model
logit union i.goodjob grade i.south##i.black i.marst, or
// See marginal odds
margins i.south#i.black, post expression(exp(xb()))
// use -esttab., part of -estout- (SSC),
// to display the results
esttab
*--------------------- begin example ----------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
http://www.maartenbuis.nl
---------------------------------
*
* 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/