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: Get list of non-omitted variables after a regression
From
"Seed, Paul" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Get list of non-omitted variables after a regression
Date
Mon, 10 Mar 2014 13:46:57 +0000
The simplest solution is to get the column names off the regression matrix.
*********** Start Stata code ***************
sysuse auto, clear
stepwise , pe(0.05) : regress price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign
local n : colnames e(b)
di "`n'"
* If you want to lose the constant...
local c _cons
local n : list n-c
di "`n'"
* Note, I am using macro extended functions to avoid silent, automatic
* truncation of macros at 245 characters whenever "=" occurs.
*********** End Stata code ******************
Paul T Seed, Women's Health, KCL
> Date: Sat, 8 Mar 2014 16:30:49 -0600
> From: Scott Merryman <[email protected]>
> Subject: Re: st: Get list of non-omitted variables after a regression
>
> See - _rmcoll , forcedrop -
>
> Scott
>
>
> On Sat, Mar 8, 2014 at 3:38 PM, Ludovico Zaraga
> <[email protected]> wrote:
> > Hello,
> >
> > Is there a simple way of getting a list (in the form of a macro) of
> > non-omitted variables after running a regression in Stata? I am using
> > a very large number of variables, so I can't do this by hand.
> >
> > Thanks,
> >
> > Ludovico
*
* 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/