<>
Hard to overstate the importance of initmate knowledge of http://www.stata.com/support/faqs/data/#manip
HTH
Martin
-------- Original-Nachricht --------
> Datum: Mon, 16 Mar 2009 14:02:58 +0100
> Von: [email protected]
> An: [email protected]
> Betreff: RE: st: replace in paneldata at specific dates
> Thank you, Martin and Nick. I was wrong in my description of the problem.
> If, within id, result equals SUCCESS later than NA according to comm_date,
> then NA does not change. Thus, changing the last part of Martins code,
>
> ...result[_N]!="SUCCESS"
>
> solved it.
>
> Thanks a lot for both pointing me to 'bys' and [_N]. Very neat! Looks
> easy, but I've spent the entire morning trying to figure this one out...
>
> Best wishes,
> Alexander Severinsen
>
> -----Opprinnelig melding-----
> Fra: [email protected]
> [mailto:[email protected]] På vegne av Nick Cox
> Sendt: 16. mars 2009 13:51
> Til: [email protected]
> Emne: RE: st: replace in paneldata at specific dates
>
> It does no harm to insist that observations are ordered by date within
> identifier:
>
> bys id (comm_date): replace result = "DM SUCCESS" if result=="NA" &
> concept=="veil" & abonaa=="FRIHET" & result[_N]=="SUCCESS"
>
> Looking through very recent threads would uncover several examples of
> the same technique.
>
> Nick
> [email protected]
>
> Martin Weiss
>
> ********clear*
>
> inp id str15 result str15 concept str15 abonaa str15 comm_date
> 300 Ei-svar veil FRIHET 30mar2008
> 300 Ei-svar veil FRIHET 19may2008
> 300 NA veil FRIHET 10jun2008
> 400 Ei-svar veil FRIHET 30mar2008
> 400 Ei-svar veil FRIHET 19may2008
> 400 NA veil FRIHET 10jun2008
> 400 FAILURE veil FRIHET 03nov2008
> 400 FAILURE veil FRIHET 17dec2008
> 400 SUCCESS veil FRIHET 14jan2009
> end
>
>
> bys id: replace result = "DM SUCCESS" if result=="NA" & concept=="veil"
> & abonaa=="FRIHET" & result[_N]=="SUCCESS"
>
> l, noo sepby(id)
> *********
>
> [email protected]
>
> > I have a panel of data that looks like this,
> >
> > id result consept abonaa comm_date
> > 400 Ei-svar veil FRIHET 30mar2008
> > 400 Ei-svar veil FRIHET 19may2008
> > 400 NA veil FRIHET 10jun2008
> > 400 FAILURE veil FRIHET 03nov2008
> > 400 FAILURE veil FRIHET 17dec2008
> > 400 SUCCESS veil FRIHET 14jan2009
> >
> > I would like to recode the variable result = "DM SUCCESS" if
> result==NA,
> > concept="veil" and abonaa="FRIHET", but only if the last comm_date for
> every
> > member of the panel is not equal to SUCCESS in the variable result. In
> > this case result = SUCCESS for comm_date=14jan2009, thus result="NA"
> stays
> > equal to NA.
> >
> > However, in this example,
> >
> > id result consept abonaa comm_date
> > 300 Ei-svar veil FRIHET 30mar2008
> > 300 Ei-svar veil FRIHET 19may2008
> > 300 NA veil FRIHET 10jun2008
> >
> > result=NA occurs at the last comm_date for id=300 thus I want to
> recode NA
> > = "DM SUCCESS"
>
> *
> * 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/
>
> *
> * 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/
--
Martin Weiss
Hackersteigle 3
72076 Tübingen
00497071/793535
00491784597218
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01
*
* 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/