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.
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 save with the early bird rate—just $795!