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
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.