Dear All.
I have a question which is very basic which I couldn't do it myself, hence seeking the help of members
Code:
input str1 firm float (profits) int year 
"a"   100 1999
"a"   .      2000
"a"   .      2001
"a"   200 2002
"b"   500  1999
"b"   800  2000
"b"   1000 2001
"b"   200  2002
"c"   .       1999
"c"   .      2000
"c"   .      2001
"c"   200  2002
end
Based on the above example dataset, I would like to create a dummy for such firms that registers a profit at least for 2 years in the panel. For instance, in the above panel, a dummy should be given for firm "a" & "b" but not for "c". I read the link
HTML Code:
https://www.stata.com/support/faqs/data-management/identifying-runs-of-consecutive-observations/
but that is for consecutive observations unlike mine.
I tried the following basic codes
Code:
encode firm,gen(id)
xtset id year
gen dummy=.
replace dummy=1 if !missing(profits) & ?
Can someone help me here?