Hi, I want to assign category to the ID 1234 if age < =24. In the below example I have 3 rows in this ID which satisfies the condition.
But I want the category to be assigned to the max age (only) available below 24 months, In this case it is 12 months.
Condition for version is either 0 or 1.
Can't figure out how to get this done. Please advise.
| ID | Age in months | Version | Category |
| 1234 | 0.032854209 | 0 | Severe |
| 1234 | 2 | 0 | Severe |
| 1234 | 12 | 0 | Severe |
Thank you
I'd use a double DO loop:
proc sort data=have;
by id age;
run;
data want;
do until (last.id);
set have;
by id;
if age le 24 then maxage = max(maxage,age);
end;
do until (last.id);
set have;
by id;
category = (maxage = age);
output;
end;
drop maxage;
run;
I'd use a double DO loop:
proc sort data=have;
by id age;
run;
data want;
do until (last.id);
set have;
by id;
if age le 24 then maxage = max(maxage,age);
end;
do until (last.id);
set have;
by id;
category = (maxage = age);
output;
end;
drop maxage;
run;
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 save with the early bird rate—just $795!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.