BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I'm very new to SAS
Please excuse my ignorance with some of my questions.
I have a social security column which is manually entered by some outside users.
Is there a way for me to check this column based on this format: XXX-XX-XXXX
I want to find the columns that don't match this format if possible.

Thank You
Jerry
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
One technique in a SAS DATA step is to use TRANSLATE such as:

DATA _NULL_;
SSN = '222-22-2222';
IF TRANSLATE(SSN,'%%%%%%%%%%','0123456789') NE '%%%-%%-%%%%' THEN PUTLOG '>ERROR> INVALID VARIABLE: ' SSN= ;
RUN;

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Scott,
Thank you again for your help. That is what I was looking for. All I have to is change it around a bit for populate the column with null if the format doesn't match.

Thank You
Jerry
deleted_user
Not applicable
Regular expressions would do this too.

A right riveting read...

http://www2.sas.com/proceedings/sugi29/265-29.pdf

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1250 views
  • 0 likes
  • 2 in conversation