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
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.
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.
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.
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.