Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: list of all variables in dataset


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: list of all variables in dataset
Date   Fri, 5 Nov 2004 18:15:49 -0000

Several. For some problems, check out -ds-. 

For this problem, you could 

foreach v of var a b c { 
	qui regress `v' i 
	di "`v' {col 2O}" _b[`i'] * 42 
} 

where 42 is a placeholder for some 
other number, 

and you then can generalise that by putting 
any wildcard in place of -a b c-. 

Some reading for the weekend: 

[P] foreach 

http://www.stata.com/support/faqs/data/foreach.html

How to face lists with fortitude. 
Stata Journal 2(2):202--222 (2002)

Problems with lists. 
Stata Journal 3(2):185--202 (2003)

Nick 
[email protected] 

Jason Rachlin
 
>  Does anyone know if there is a simple (or not so simple) way 
> to create a
> varlist of all the variables in the dataset.  I'd like to 
> loop across my
> variables regressing on another variable so I can predict 
> values for each
> variable under an assumption about my independent variable.
> 
> For example if I have three variables a, b, and c, and 
> another independent
> variable i, I'd like to regress a i , regress b i, and 
> regress c i and after
> each regression take the coef and multiply it by a value of i 
> to predict an
> outcome.  The problem is that I have an unknown number of 
> variables and I'd
> like to be able take the full list and loop across it.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index