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

Hi,

I am very new with SAS. I have a dataset like this:

ID_num     Start_Date        End_Date           Other_cols

001           01/01/2018       05/03/2018              ....

001           05/03/2018       10/08/2018              ....

001           10/08/2018       12/11/2018              ....

001           12/11/2018       11/01/2019              ....

002           05/04/2018       07/07/2018              ....

002           07/07/2018       20/12/2019              ....

003           01/05/2018       17/09/2018              ....

003           17/09/2018       17/03/2019             ....

003           17/03/2019       20/05/2019              ....

004           19/08/2019       28/09/2019             ....

004           28/09/2019       30/12/2019              ....

 

I would like to extract all the rows of ID having the max(end_date) = 31/05/2019, so with end_date(ID) <= 31/05/2019. My output should have all rows of ID 001 and ID 003. Could you help me?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

Can be solved with group by and having in proc sql:

proc sql;
   create table want as
   select *
      from have
         group by d_Num
            having max(End_Date) <= '31May2019'd
   ;
quit;

View solution in original post

1 REPLY 1
andreas_lds
Jade | Level 19

Can be solved with group by and having in proc sql:

proc sql;
   create table want as
   select *
      from have
         group by d_Num
            having max(End_Date) <= '31May2019'd
   ;
quit;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 633 views
  • 0 likes
  • 2 in conversation