Home › Forums › Main Forums › SAS Forum › Find the persons who joined the games at least 3 years consecutively…
-
Find the persons who joined the games at least 3 years consecutively…
-
data AAA;
Input Name $ Year;
cards;
John 2003
Lyla 1994
Faith 1996
John 2002
Carol 2000
Carol 1999
John 2001
Carol 2002
Lyla 1996
Lyla 1997
Carol 2001
John 2009
;
run; -
proc sql;
create table CCC as
select a.*,
b.Year as Year_2,
c.Year as Year_3from AAA a inner join AAA b
on a.Name=b.Name and a.Year=b.Year +1
inner join AAA c
on a.Name=c.Name and a.Year=c.Year +2
order by a.Name, a.Year;create table Output as
select distinct Name
from CCC;
run;
Log in to reply.