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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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