Hello, this is the dataset I have available:
data Have; input ID arrange_date :ddmmyy. datestamp :ddmmyy.; format arrange_date datestamp ddmmyy10.; datalines; 001 05/06/2020 01/06/2020 001 05/07/2020 01/06/2020 001 05/08/2020 01/06/2020 001 05/06/2020 02/06/2020 001 05/07/2020 02/06/2020 001 05/08/2020 02/06/2020 001 05/06/2020 03/06/2020 001 05/07/2020 03/06/2020 001 05/08/2020 03/06/2020
001 10/10/2020 03/10/2020 001 10/11/2020 03/10/2020 001 10/12/2020 03/10/2020 001 10/10/2020 04/10/2020 001 10/11/2020 04/10/2020 001 10/12/2020 04/10/2020
002 20/03/2020 10/03/2020 002 20/04/2020 10/03/2020 002 20/05/2020 10/03/2020 002 20/06/2020 10/03/2020 002 20/03/2020 11/03/2020 002 20/04/2020 11/03/2020 002 20/05/2020 11/03/2020 002 20/06/2020 11/03/2020; run;
To clarify:
-There are many client ID's.
-The second column refers to certain arranged dates when the client needs to perform an action.
-The third column is the datestamp.
-There is one row per client's arrangement date, per datestamp. As you can see, client 001 has two different "periods" in this table, one that goes from 05/06 and another that starts in 10/10.
I'm interested in keeping only the first unique occurrences of arrange_date. In this case it would look like this:
data Have;
input ID arrange_date :ddmmyy. datestamp :ddmmyy.;
format arrange_date datestamp ddmmyy10.;
datalines;
001 05/06/2020 01/06/2020
001 05/07/2020 01/06/2020
001 05/08/2020 01/06/2020
001 10/10/2020 03/10/2020
001 10/11/2020 03/10/2020
001 10/12/2020 03/10/2020
002 20/03/2020 10/03/2020
002 20/04/2020 10/03/2020
002 20/05/2020 10/03/2020
002 20/06/2020 10/03/2020
;
run;
As you can see, I only kept the first occurrence of each "arrange_date".
I'm okay if it's done either in proc sql or a data step.
Try
proc sort data=have out=want nodupkey;
by id arrange_date;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.