I would like to create a code that fill in a variable with the value which is the id corresponding to a minimum age. In case you have more than one ID with the same minimum age, Iwould like to bring the smallest ID (containing the smallest age) for the variable ID_AGE_MIN, e.g:
data have;
input ID AGE;
datalines;
1 13
2 25
3 7
;
proc sql;
create table want as
select *, (select id from have having min(age)=age) as id_min_age
from have;
quit;
data have;
input ID AGE;
datalines;
1 13
2 25
3 7
;
proc sql;
create table want as
select *, (select id from have having min(age)=age) as id_min_age
from have;
quit;
It's perfect. I just had one problem: In case you have more than one ID with the same minimum age. In this case, I would like to bring the smallest ID (containing the smallest age) for the variable ID_AGE_MIN.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.