I'm trying to return unique emails for specific IDs. Some IDs have multiple emails but sometimes there are duplicates. I'm thinking a loop might do it but I can't seem to figure it out.
HAVE
ID ACCOUNT_EMAIL
114 [email protected]
114 [email protected]
114 [email protected]
114 .
WANT
ID ACCOUNT_EMAIL
114 [email protected]
114 [email protected]
CREATE TABLE test AS
SELECT DISTINCT
ID
,UPPER(ACCOUNTEMAILADDRESS) AS Account_Email
FROM DATABASE
;QUIT;
PROC SORT DATA=test;
BY ID
descending Account_Email;
Run;
DATA test;
SET test;
BY ID descending Account_Email;
IF last.Account_Email AND Account_Email = '' THEN dupIND = "Y";
ELSE dupIND = "N";
;RUN;
If the data is not sorted you can use a hash object to track observed keys (id+email)