Hi Experts
How to extract last 10 digits without substr ,scan ,reverse ,regex functions
data dsn;
input phone $ 50.;
cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;
run;
I don't accept your restrictions, and so it is easy to do. No reason to make it harder.
In this case, use the SCAN function.
last_10=scan(phone,3,' ');
This is not difficult for SAS:
data dsn;
length phone $ 50;
input phone phone phone;
cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;
But why would you want to prohibit the most useful tools. To illustrate, here's a task for you. Try to eat a bowl of cereal and milk without using a spoon.
It looks like an interview question ?
data dsn;
input phone $ 50.;
length dummy $ 12;
dummy=phone;
want=strip(tranwrd(phone,dummy,' '));
drop dummy;
cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: