Date: Tue, 2 Dec 2003 08:46:29 -0500
Reply-To: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Subject: Re: Email Address Validation SAS code
Hi, mmxell,
To quote Christiansen and Torkington(1998, "Perl Cookbook");
"Problem
"You want to find a pattern that will verify the validity of a supplied [e-
]mail address.
"Solution
"There ins't one. You cannot do real-time validation of [e-]mail
addresses. You must pick from a number of compromises."
They continue:
"Our best advice of verifying a person's [e-]mail address is to have them
enter their address twice..."
Well, some of the better "compromised approaches" are based on regular
expressions. One from Friedl(2002 "Mastering Regular Expressions," 2nd
ed.) goes like: (I have no idea if SAS prx can handle this, but it should,
since it claims compatibility.)
\w[-.\w]*\@[-a-z0-9]+(\.[-a-z0-9]+)*\.
(com|edu|gov|int|mil|net|org|biz|info|name|museum|coop|aero|[a-z][a-z])
And you need /i modifier to disregard capitalization. HTH!
Cheers,
Chang
On Tue, 2 Dec 2003 17:51:32 +0800, mmxell <docdoc1357@TIPGOD.COM> wrote:
>Hi Experts,
>I have a dataset containing email addresses entered by users (however,
there
>was no front-end validation was built in the input form). I tried to use
>SAS to delete the invalid email addresses (sample code as below) but the
it
>always delete all records in the set. Someone know what's wrong with the
>code?
>Also, anyone has a more comprehensive code for validation?
>Many Thanks
>
>proc sql;
>delete from source
>where email is null or email like '@%' or email like '%@' or email like
>'%..%' or
>email like '%@@%' or email like '%@%@%' or email like '% %' or
>email like "%'%'%" or email like '%$%' or email like '%<%' or email like
>'%{%' or
>email like '%}%' or email like '%,%' or email like '%@.%' or email like
>'%'%' or
>email like '%\%' or email like '%/%' or email like '%(%' or email like
>'%)%' or
>email like '%`%' or email like '%.' or email like '.%' or email like
>'%;%' or
>email like '%:%' or email like '%:%' or email like '%^%' or email like
>'%!%' or
>email like '%.@%' or email like '%#%' or email like '%[%' or email like
>'%]%' or
>email like '%'%' or email like '%?%' or email like '%~%' or email like
>'%@_%' or
>email Not like '%@%' or email like '%@=%' or email like '%@%=%' or
>email Not like '%.%' or email Not like '%@%.%';
>quit;