If it's first occurrences in spells that are critical, then see my other
postings on that topic today.
Nick
[email protected]
Nick Cox
The key (and only) difficulty here seems to be identifying first
occurrences (and only those).
How to tackle that is an FAQ:
. search first occurrence
FAQ . . . . . . . . . . . . . . . First and last occurrences in
panel data
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N.
J. Cox
3/07 How can I identify first and last occurrences
systematically in panel data?
<http://www.stata.com/support/faqs/data/firstoccur.html>
You can tag successive occurrences like this
gen noccur = sum(var == "diathermy[2]")
The first occurrence is then defined by
... if noccur == 1 & noccur[_n-1] == 0
The FAQ explains how to apply this approach to panel data. If you don't
have panel data, there is no problem, as the code above should suffice.
Nick
[email protected]
b. water
stata 8.2 xp pro,
i have a var like this:
monopolar
bipolar
bipolar
bipolar
monopolar
nodiathrm
diathermy[2]
diathermy[2]
bipolar
monopolar
diathermy[2]
diathermy[2]
.
. <- denotes missing
.
monopolar
diathermy[2]
diathermy[2]
.
.
what i want to achieve is for every first encountered diathermy[2] to be
changed to diathermy[1], while leaving the second occurence as
diathermy[2]. is this possible in stata? if it can be done, would
appreciate advice/help on how to achieve it.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/