Hi,
I was wondering if it's possible to go over a list of observations
with the foreach command. What I mean is the following: I have a data
set with persons identified by a (for the person) unique number,
called rin. However, when personal characteristics of the people in
the data set changed, a new record was made with the same
identification number. Now the problem is, that if certain
characteristics for a person have changed (which gives a mutation code
of 1 (mutcode==1)), I want that person out of the data set.
What I tried is the following. The list of identification numbers that
I want out of the dataset can be obtained by this command:
list rin if mutcode==1
However, I don't want to run "drop if rin==number" by hand, since
there are many observations. Therefore, I tried the following:
foreach x of l rin if mutcode==1 {
drop if rin=="`x'"
}
Which doesn't work, unfortunately. I tried some other commands as well:
foreach x of rin if mutcode==1 {
drop if rin=="`x'"
}
and
foreach x in l rin if mutcode==1 {
drop if rin=="`x'"
}
Which also don't work. I'm probably doing something very wrong here,
but I would really appreciate it if someone could take the time to
help me out with this.
Thanks,
Sander
*
* 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/