@AB1976 Something like below should work.
proc sql;
select
CASE
WHEN
EMAIL_ADRES_X LIKE '%_@__%.__%'
AND prxmatch('/\b[a-zA-Z0-9\._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}\b/i', strip(EMAIL_ADRES_X)) = 1
THEN 1
ELSE 0
END AS email_conformity
FROM have
;
quit;
Like SQL Server patindex() SAS prxmatch() will return the starting position of a match or zero if it isn't found.
From the looks of it your RegEx got some "issues" - especially the full stop that's not masked and though stands for any character.
Instead of inventing a email validation RegEx yourself I'd Google for it. Below one way how you could modify your current syntax.
data have;
EMAIL_ADRES_X='firstname.lastname@somecompany.com'; output;
EMAIL_ADRES_X='..@somecompany.com'; output;
run;
proc sql;
select
CASE
WHEN
prxmatch('/^[a-z0-9][\w\.-]+@[\w\.-]+\.[a-z]{2,6}$/oi', strip(EMAIL_ADRES_X)) = 1 THEN 1
ELSE 0
END AS email_conformity
FROM have
;
quit;
... View more