Hi,
I have a dataset like below:
id date type
1 SEP A
1 SEP B
1 SEP C
2 SEP B
3 SEP C
4 SEP B
4 SEP C
I want like below: group by id,date, if this id in specific time, in all the type he has, if he has type A then his new type will be A and ignore other type.
so the important type should be A>B>C.
id date type_new
1 SEP A
2 SEP B
3 SEP C
4 SEP B
how can I solve this? Thank you!
I would keep a look up table like, and it;s easy to update look up table when needed
Type rank
a 1
b 2
c 3
and look up using join, merge, hash,format etc
if the type is actually A,B,C etc ranked i.e sorted by hierarchy as your sample is
all you need is
data want;
set have;
by id date type;
if first.id;
run;
I would keep a look up table like, and it;s easy to update look up table when needed
Type rank
a 1
b 2
c 3
and look up using join, merge, hash,format etc
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.