I want to create a three indicators for a variable. I have a dataset that looks like this:-
ID Group Color
1763 A Red
1763 A Yellow
6372 B Red
0498 A Red
I want to account for when I have two rows with the same ID with different values in the column, Color (either Red or Yellow) and label it with an additional indicator. Then have distinct IDs in my output dataset.
proc sql;
create table want as
select a.ID
a.Qty
(case when b.Group = 'A' then 'R'
when b.Group = 'B' then 'L'
when b.Color = 'Red' AND b.Group ='A' then 'R/L'
when b.Color = 'Yellow' AND b.Group = 'B' then 'R/L'
else 'X' end) as Category
from work.test a
left join (select distinct ID, Group, Color from work.have) b
on a.ID=b.ID
;
quit;
I would like the dataset to look like this:-
ID Qty Category
1763 28 R/L
6372 30 L
3908 41 X
0498 32 R