LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: docdoc1357@TIPGOD.COM

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;


Back to: Top of message | Previous page | Main SAS-L page