Hi all,
I've got decent help here and am still looking for more.
This time I am trying to find records with minimum values. My sample data looks like below:
| personid | days_gap |
| 1 | 0 |
| 1 | 0 |
| 1 | 10 |
| 1 | 10 |
| 1 | 10 |
| 1 | 15 |
| 2 | 9 |
| 2 | 9 |
| 2 | 9 |
| 2 | 9 |
| 2 | 24 |
| 2 | 24 |
| 2 | 30 |
| 2 | 30 |
| 3 | 1 |
| 3 | 6 |
| 3 | 6 |
| 3 | 8 |
| 3 | 8 |
| 3 | 8 |
| 3 | 9 |
| 3 | 9 |
| 3 | 9 |
My target data is
| personid | days_gap |
| 1 | 0 |
| 1 | 0 |
| 2 | 9 |
| 2 | 9 |
| 2 | 9 |
| 2 | 9 |
| 3 | 1 |
That is, I want to find records with minimum value of days_gap for each personid. Does anyone know a way to do it?
Thanks a lot as always!
Lizi
proc sql;
create table want as
select * from have
group by personid
having days_gap=min(days_gap);
quit;
proc sql;
create table want as
select * from have
group by personid
having days_gap=min(days_gap);
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!
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.