Hi everyone,
I have a data sample like this:
Firm Year IPO_year
A 2000 0
A 2001 1
A 2002 0
A 2003 0
B 2007 0
B 2008 1
B 2009 0
C 2013 0
C 2014 0
I want to count the number of years after IPO for each firm, so what I want to get is another column like this:
Firm Year IPO_year Year_After_IPO
A 2000 0 0
A 2001 1 1
A 2002 0 2
A 2003 0 3
B 2007 0 0
B 2008 1 1
B 2009 0 2
C 2013 0 0
C 2014 0 0
(All the years before IPO will be zero).
I have tried this code:
data X;
set Y;
by Firm;
if IPO_year = 1 then d+1;
run;
but this code is not reset for new firm. Could any one can help me with this?
Thank you very much in advance!