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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.