Hi , wherever the Number(lessthen five count),Characters and Special Character are availabel then that should be return as "0" and only numbers count greaterthen or equal to 5 then that should return as "1 in sas EG.Kindly help.
| have | Length | want |
| 123456 | 6 | 1 |
| 1234567 | 7 | 1 |
| 12345678 | 8 | 1 |
| 123456789 | 9 | 1 |
| 110ask- | 7 | 0 |
| _wertn | 6 | 0 |
| gst | 3 | 0 |
| 123 | 3 | 0 |
| 1526 | 4 | 0 |
| 12356 | 5 | 1 |
Thanks,
Siva
Hello,
data have;
input x $9.;
drop toNum;
toNum=input(x, ? 9.);
if toNum>9999 and strip(put(toNum,9.))=strip(x) then y=1;
else y=0;
cards;
123456
1234567
12345678
123456789
110ask-
_wertn
gst
123
1526
12356
;
run;
Hello,
data have;
input x $9.;
drop toNum;
toNum=input(x, ? 9.);
if toNum>9999 and strip(put(toNum,9.))=strip(x) then y=1;
else y=0;
cards;
123456
1234567
12345678
123456789
110ask-
_wertn
gst
123
1526
12356
;
run;
if notdigit(substr(have,1,length(have))) ne 0 or length(have) < 5
then want = 0;
else want = 1;
data have; input x $9.; length=length(x); if length ge 5 and notdigit(strip(x))=0 then flag=1; else flag=0; cards; 123456 1234567 12345678 123456789 110ask- _wertn gst 123 1526 12356 ; run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.