Hi all,
I have a rather large dataset with two fields, phone1 and phone2. These are text based fields with up to 10 digit phone numbers, no special characters.
I'm looking for some ideas on how to set a flag field based on what could be a valid number, which is to say if the field is '0000000000', '4488888888', '999999', etc... I'd like to set a flag to mark it as potential unviable.
I've taken a stab at both proc sql (case statements) and data step (if/else) but I feel like I'm being inefficiant with my approach.
Any ideas?
Thanks in advance.
Hi @Ody,
I think, before you start coding, you should write down specifications. Once you have a (preliminary) list of criteria (like "less than 5 digits", "more than 5 repetitions of the same digit", etc.), it will be fairly straightforward to program the corresponding IF conditions in a data step (maybe using the PRX functions). And many people in the forum will be able to support you.
PROC SQL will probably not come into play, unless you include criteria involving more than one observation at a time (like "more than 3 records have the same phone numbers").
Wow, thanks for the link and feedback. Not sure why I didn't think of Googling that myself...
EDIT: The solution in the linked document worked beautifully. I made some modifications based on what I'm looking for but that gave me a great start. Thanks!!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.