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

st: RE: selecting all variables but a few


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: selecting all variables but a few
Date   Tue, 11 May 2004 19:38:04 +0100

There are several ways to do this. 

One is 

. ds <varlist>, not 

This returns all variables _except_ those 
in <varlist>, after which you can go

foreach v of var `r(varlist)' { 
	...
} 

Also look at the options of -ds-. 

Another is to use the facilities in 
-macrolists-. See -whelp macrolists-. 

For what looks like your particular 
problem here, check out 
http://www.stata.com/support/faqs/data/missing.html



Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Ada Ma
> Sent: 11 May 2004 19:29
> To: [email protected]
> Subject: st: selecting all variables but a few
> 
> 
> Hello Statalist,
> 
> I want to do something like this:
> 
> foreach var of varlist * {
> replace `var'=`var'[_n-1] if pid==pid[_n-1] & `var'==.
> replace `var'=`var'[_n+1] if pid==pid[_n+1] & `var'==.
> }
> 
> My problem is that I have a large number of variables in my 
> dataset and I don't 
>   want my commands to be applied to ALL variables.  What 
> commands can I use to 
> select all variables but a few?
> 
> Many thanks in advance.
> 
> Ada
> 
> 
> 
> 
> 
> -- 
> Ada Ma
> Research Assistant
> Department of Economics
> University of Aberdeen Business School
> Edward Wright Building F55
> http://www.abdn.ac.uk/economics/
> http://www.abdn.ac.uk/~pec187/firstpage.htm
> Tel:   +44 1224 273417
> Fax:   +44 1224 272181
> Email: [email protected]
> 
> *
> *   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/
> 

*
*   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