Thanks Reinhard, your code works, but it doesn't work when 101 by group don't have an email and 104 has only email (see the following below). I want Home, Mobile and Cellular as priority order. If all are missing, then I don't want that observation (104 in this case). Can you please help further. Thanks,
data have; input ID (Contact_type Contact) ( & $20.); cards;
101 Home 4434323454 101 Mobile 8767876546 102 Mobile 8987609878 102 Email ghg@gmail.com 103 Email aaa@gmail.com 103 Cellular 6779998786 104 Email sss@gmail.com ; RUN
proc sql; create table want(drop=priority) as select *, whichc(Contact_Type, 'Home', 'Mobile', 'Cellular') as priority from have where not missing(Contact) group by id having priority=min(priority); quit;
Folowing is my expected output:
101 Home 4434323454 102 Mobile 8987609878 103 Cellular 6779998786
... View more