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: Getting all independent vars from a set of reg equations

From   Maarten Buis <>
Subject   Re: st: Getting all independent vars from a set of reg equations
Date   Sun, 26 Jun 2011 17:50:06 +0200

On Sat, Jun 25, 2011 at 3:45 PM, Narahari H.S. wrote:
> I have to present a correlation matrix of all independent variables from a set of regression equations. I thought that if I could list (in one place) all the independent variables from all the equations, I could use them with the pwcorr command.

You can get the independent variables of one regression model using
-indeplist- (which is available form SSC). If you have multiple
models, you need to know some tricks on how to deal with local macros
in Stata. Below is an example with three models. First I stack all the
names in one local macro `x', and than I drop the duplicate names
using -local x: list uniq x-.

*---------------- begin example -----------------------
sysuse auto

reg price mpg foreign
local x = r(X)

reg price mpg rep78 foreign
local x "`x' `r(X)'"

reg price mpg rep78 foreign gear_ratio
local x "`x' `r(X)'"

di "`x'"

local x : list uniq x
di "`x'"

cor `x'
*------------------ end example ----------------------
(For more on examples I sent to the Statalist see: )

Hope this helps,

Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
*   For searches and help try:

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