Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: replace in paneldata at specific dates


From   <Alexander.Severinsen@telenor.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: replace in paneldata at specific dates
Date   Mon, 16 Mar 2009 11:35:23 +0100

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"

Any suggestions would be appreciated?

Best wishes,
Alexander Severinsen 

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



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