Hello, if possible in spl I would like to keep the last status with respect to the oldest date of the column (DH_EVNM)
Table:
Code | DT_DEPO | DH_EVNM | CD_STTT_APPL |
PIZ640 | 23FEB2022:00:00:00 | 23FEB2022:10:09:39.000000 | REPONDEUR SYSTEM |
PIZ640 | 23FEB2022:00:00:00 | 24FEB2022:10:35:00.000000 | REFUS PAS INTERESSE PAR L OFFRE |
PIZ640 | 23FEB2022:00:00:00 | 24FEB2022:10:35:21.000000 | REFUS PAS INTERESSE PAR L OFFRE |
PIZ541 | 16APR2022:00:00:00 | 16APR2022:11:46:13.000000 | REPONDEUR SYSTEM |
PIZ541 | 16APR2022:00:00:00 | 19APR2022:11:23:38.000000 | REPONDEUR SYSTEM |
PIZ541 | 16APR2022:00:00:00 | 20APR2022:11:04:00.000000 | REFUS PAS INTERESSE PAR L OFFRE |
PIZ541 | 16APR2022:00:00:00 | 20APR2022:11:04:26.000000 | REFUS PAS INTERESSE PAR L OFFRE |
PIZ324 | 04JUN2022:00:00:00 | 07JUN2022:14:54:54.000000 | REPONDEUR SYSTEM |
PIZ324 | 04JUN2022:00:00:00 | 08JUN2022:16:18:43.000000 | REPONDEUR SYSTEM |
PIZ324 | 04JUN2022:00:00:00 | 09JUN2022:13:48:21.000000 | REPONDEUR SYSTEM |
PIZ324 | 04JUN2022:00:00:00 | 10JUN2022:17:27:42.000000 | REPONDEUR SYSTEM |
PIZ324 | 04JUN2022:00:00:00 | 13JUN2022:17:28:00.000000 | GEL AU JOUR 5 |
PIZ811 | 17NOV2022:00:00:00 | 17NOV2022:11:36:45.000000 | REPONDEUR SYSTEM |
PIZ811 | 17NOV2022:00:00:00 | 17NOV2022:17:53:39.000000 | REPONDEUR SYSTEM |
PIZ811 | 17NOV2022:00:00:00 | 18NOV2022:12:08:46.000000 | REPONDEUR |
PIZ811 | 17NOV2022:00:00:00 | 18NOV2022:16:12:39.000000 | REPONDEUR |
PIZ811 | 17NOV2022:00:00:00 | 19NOV2022:11:14:16.000000 | REPONDEUR |
PIZ811 | 17NOV2022:00:00:00 | 19NOV2022:13:49:00.000000 |
TENTATIVES D APPELS ATTEINTES |
Want:
Code | DT_DEPO | DH_EVNM | CD_STTT_APPL |
PIZ640 | 23FEB2022:00:00:00 | 24FEB2022:10:35:21.000000 | REFUS PAS INTERESSE PAR L OFFRE |
PIZ541 | 16APR2022:00:00:00 | 20APR2022:11:04:26.000000 | REFUS PAS INTERESSE PAR L OFFRE |
PIZ324 | 04JUN2022:00:00:00 | 13JUN2022:17:28:00.000000 | GEL AU JOUR 5 |
PIZ811 | 17NOV2022:00:00:00 | 19NOV2022:13:49:00.000000 | TENTATIVES D APPELS ATTEINTES |
Thanks for your help.
After making sure that the sort order of your data is in CODE DH_EVNM order then (Sort your existing data)
data want; set have; by code; if last.code; run;
Your shown example is the most recent, not oldest, by datetime value.
The BY statement in the data step creates automatic variables First. and Last. for each by variable. These are 1/0 coded numeric variables so if the current record is the last one of a by group the If selects it for retention in the output data.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: