Epidemiology & Technology

Compact Results of Logistic Regression in Stata using ‘estout’ – ‘logisticresults’

After running a logistic regression in Stata, for inclusion in classical tables, one needs the Odds ratios and 95% confidence intervals. I have developed a small code snippet for getting reasonably compact unstyled results that can be easily copy-pasted in word or excel. This actts as a thin wrapper for ‘estout’ commands.

logisticresults – Stata

It depends on ‘estout’ program for generating table. SO that needs to be installed first

findit estout
* Latest versions as on Feb 2024
net install st0085_2.pkg
net get st0085_2.pkg
Code language: JavaScript (javascript)

Load the program in Stata memory by running the commands below. Then ‘ ‘logisticresults’ is ready for use:

** STATA Program **
cap program drop logisticResults
program define logisticResults
	qui cap est drop tempvar
	qui  est store tempvar
	estout tempvar ,   cells (" b(fmt(2))    ci(par( ( , ) )) p(fmt(3)) ") label   eform  
	qui cap est drop tempvar
Code language: JavaScript (javascript)

Usage of logisticresults

Run the logistic regression as you normally would and then run logisticResults. I prefer to run it quietly, after teting the outpuit and matching the logistic results once

logistic coVi360prev i.ageGrp   i.sex ib4.option1   i.rural  ib6.distZone
logisticResultsCode language: CSS (css)

View the compact results

Related posts