Hi,
How to find the correct PAN # in a given data.
data can be in any format..A PAN should be first 5 chars,fallowed by 4 digits and ends with char...need to create a flag where PAN is in correct FORMAT on not.
data test;
input tt $10.
cards;
abcde1234f
bcdef2345g
bh4hg2351h
1235456797
;
run;
In my above data 1st and 2nd records are in correct format, other records should be flogged with "incorrect". My question is that, i want data in correct format i.e 1st and 2nd obs.
can any one help, that should be appreciated.
Thanks,
Yaswanth
or split it into three part to judge ,
data test; input tt $10.; if length(tt) = 10 then do; if notalpha(substr(tt,1,5)) or notdigit(substr(tt,6,4)) or notalpha(substr(tt,10,1)) then found=0;else found=1; end; cards; abcde1234f bcdef2345g bh4hg2351h 1235456797 ; run;
Ksharp
It is easy for Perl Regular Expression.
data test; input tt $10.; pid=prxparse('/^[a-zA-Z]{5,5}\d{4,4}[a-zA-Z]$/'); if prxmatch(pid,tt) then found=1;else found=0; drop pid; cards; abcde1234f bcdef2345g bh4hg2351h 1235456797 ; run;
Ksharp
Hi Ksharp,
Thanks For your quick reply..
is there any other ways to do this.. i was pretty new to "prxparse" expressions. i can not able to understand the expression..
Thanks,
Yaswanth
or split it into three part to judge ,
data test; input tt $10.; if length(tt) = 10 then do; if notalpha(substr(tt,1,5)) or notdigit(substr(tt,6,4)) or notalpha(substr(tt,10,1)) then found=0;else found=1; end; cards; abcde1234f bcdef2345g bh4hg2351h 1235456797 ; run;
Ksharp
Hi Ksharp,
Thank you..it is working
Regards,
Yaswanth J.
Hi Ksharp..
Bit Simplified your Solution..
data test;
input tt $10.;
if Sum(notalpha(substr(tt,1,5)),notdigit(substr(tt,6,4)),notalpha(substr(tt,10,1))) then found=0;else found=1;
cards;
abcde1234f
bcdef2345g
bh4hg2351h
1235456797
abcde1234f8
;
run;
Proc print;
run;
Per my knowledge "if length(tt) = 10 then do;" condition was not required in your program because already Length of the TT variable mentioned as 10 in input statement.:-)
Thanks & Regards..
Sanjeev.K
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.