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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.