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

Re: st: RE: selecting all variables but a few

From   Ada Ma <>
Subject   Re: st: RE: selecting all variables but a few
Date   Tue, 11 May 2004 21:11:04 +0100

Hi Nick,

Thanks a lot for the link and the codes, especially the -missing- command.
Now I can pry myself off the chair and leave my office!!



Nick Cox wrote:

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


-----Original Message-----
[]On Behalf Of Ada Ma
Sent: 11 May 2004 19:29
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 Ma
Research Assistant
Department of Economics
University of Aberdeen Business School
Edward Wright Building F55
Tel:   +44 1224 273417
Fax:   +44 1224 272181

*   For searches and help try:

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