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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1300 views
  • 0 likes
  • 2 in conversation