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
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.