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…

     Justin updated 2 years, 8 months ago 1 Member · 2 Posts
  • Justin

    Administrator
    August 3, 2021 at 7:05 pm

    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;

  • Justin

    Administrator
    August 3, 2021 at 7:07 pm

    proc sql;
    create table CCC as
    select a.*,
    b.Year as Year_2,
    c.Year as Year_3

    from 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.

Original Post
0 of 0 posts June 2018
Now