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
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!
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.