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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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