BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Lauren22
Fluorite | Level 6

How do i use perl regular expression to pick up -00- in the 4th and 5th position of an ssn number?

1 ACCEPTED SOLUTION

Accepted Solutions
Lauren22
Fluorite | Level 6

Am trying to clean a data set with fake ssn like this one 000-00-0000, most of the fake one have 00 in the 4 and 5th position or the 0000 as the last four digits.

View solution in original post

4 REPLIES 4
Lauren22
Fluorite | Level 6

'/(\d{3})-(00)-(\d{4})/' 

i tried the code above but didn't work... thanks.

actuarial
Obsidian | Level 7
What are you trying to do?
Lauren22
Fluorite | Level 6

Am trying to clean a data set with fake ssn like this one 000-00-0000, most of the fake one have 00 in the 4 and 5th position or the 0000 as the last four digits.

ballardw
Super User

One thing that you may want to check is if the value is actually a character value. SAS has a SSN format that displays numbers intended to be SSN with dashes and may make you think it is character when actually numeric. The regular expressions tend not work as expected on actual numeric values.

 

If character I might look to SCAN as well

 

if scan(variable,2,'-')='00' or scan(variable,3,'-')='0000' then <whatever when found>

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 833 views
  • 1 like
  • 3 in conversation