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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 320 views
  • 1 like
  • 2 in conversation