Thanks for your response.
I start sas after python and r so I wanted to know how to write this program in sas and not in proc sql.
I found a solution but it is too long in my opinion.
My solution: data have; length start_date $10 end_date $10; input id_1 1-3 id_2 4-5 start_date $ end_date $; datalines; 111 1 17/01/2000 25/09/2001 111 1 17/01/2000 23/10/2001 111 1 17/01/2000 29/12/2002 123 1 27/05/1999 17/01/2000 145 1 29/12/2002 16/09/2014 ; run; data have1; set have; start_date1 = input(start_date, ddmmyy10.); end_date1 = input(end_date, ddmmyy10.); drop start_date end_date; rename start_date1= start_date end_date1 = end_date; format start_date1 end_date1 ddmmyy10.; run; proc sort data=have1; by id_1 id_2 start_date end_date; run; data want; set have1; by id_1 id_2 start_date end_date; retain start_new end_new; if first.id_2 then do; start_new = start_date; end_new = end_date; if first.id_2 and last.id_2 then output; end; else if start_new=start_date then do; end_new=end_date; if last.id_2 then output; end; drop end_date start_date; FORMAT start_new end_new ddmmyy10.; run; proc sort data=want; by id_2 start_new end_new; run; Is there a way to write it in a shorter way? Thank you very much :)
... View more