Help using Base SAS procedures

Checking Column based on format

Reply
N/A
Posts: 0

Checking Column based on format

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
Super Contributor
Super Contributor
Posts: 3,174

Re: Checking Column based on format

Posted in reply to deleted_user
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.
N/A
Posts: 0

Re: Checking Column based on format

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
N/A
Posts: 0

Re: Checking Column based on format

Regular expressions would do this too.

A right riveting read...

http://www2.sas.com/proceedings/sugi29/265-29.pdf
Ask a Question
Discussion stats
  • 3 replies
  • 103 views
  • 0 likes
  • 2 in conversation