Bookmark and Share

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

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

Re: st: Output format after 'margins'

From   Maarten Buis <>
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 <>, 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.marst, or

// See marginal odds
margins, post expression(exp(xb()))

// use -esttab., part of -estout- (SSC),
// to display the results
*--------------------- begin example ----------------------
(For more on examples I sent to the Statalist see: )

Maarten L. Buis
Reichpietschufer 50
10785 Berlin
*   For searches and help try:

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