BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dapenDaniel
Obsidian | Level 7

Hi,

 

I have a panel dataset like below.

 

FirmID           Year

1001             1995

1001             1996

1001             1997

1001             1998

1002              2011

1002             2012

1003             1992

1004             2015

1004             2016

1004             2017

 

I would like to delete firms that exist for less than 3 years. In my data above, firm 1002 and 1003 should be deleted.

 

What program do I need to use? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
input FirmID           Year	;
cards;
1001             1995
1001             1996
1001             1997
1001             1998
1002              2011
1002             2012
1003             1992
1004             2015
1004             2016
1004             2017
;

proc sql;
create table want as
select *
from have
group by firmid
having count(year)>=3
order by firmid, year;
quit;

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20
data have;
input FirmID           Year	;
cards;
1001             1995
1001             1996
1001             1997
1001             1998
1002              2011
1002             2012
1003             1992
1004             2015
1004             2016
1004             2017
;

proc sql;
create table want as
select *
from have
group by firmid
having count(year)>=3
order by firmid, year;
quit;