DATA Step, Macro, Functions and more

SAS code in checking a valid telephone number and email address

Reply
Occasional Contributor
Posts: 6

SAS code in checking a valid telephone number and email address

Hi guys,

 

Would like to check if there are any SAS intelligence in coding to check whether the phone number or an email in dataset is a valid one?

 

Thanks for the sharing.

 

With sincere regards,

Nicolas

PROC Star
Posts: 1,215

Re: SAS code in checking a valid telephone number and email address

Posted in reply to nicolaskan

You have to be much more specific than that. What does "a valid one" mean? Show us some example data and explain what valid means in this context.

Super User
Posts: 9,890

Re: SAS code in checking a valid telephone number and email address

Posted in reply to nicolaskan

There are ways to check the validity of an email, but they only work if the target server cooperates (which is often turned off to make spamming harder). So you are left with sending a email and checking for a response, which is best done through a proper email client.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 13,321

Re: SAS code in checking a valid telephone number and email address

Posted in reply to nicolaskan

Phone number rules would be needed. And if you have multiple countries involved you may need additional rules for each. Such as determining international country codes as part of the numbers.

 

Likely bits may be looking for patterns of spaces, periods, commas, dashes(of multiple characters such as (208) 123-4567 or 208-123-4567, 208.123.4567 and so on.

If the original field is manually entered and there are not appropriate constraints you may have to find things like ext 123 (office extensions) and similar.

Note that removing all non-numeric characters and then checking may be insufficient as international codes may make a number look like another source.

Community Manager
Posts: 3,379

Re: SAS code in checking a valid telephone number and email address

For e-mail, using a regular expression similar to the one you have is probably best.  That validates the form of the e-mail address, not whether it's active (of course!).  If you use PRXPARSE to compile the pattern and then PRXMATCH to check for it, it should be pretty fast.  I have an example of that in this article about validating variable names.


For phone numbers, check out this tip by @Ron_Cody about standardizing phone numbers in your data.  You could standardize and QC the phone numbers in one pass through the data.

 

 

Ask a Question
Discussion stats
  • 4 replies
  • 125 views
  • 0 likes
  • 5 in conversation