Will someone provide me the solution for subjected problem with the below data, I want to extract age from the below data using 'Length' and 'Substr' function.
Data test; input nameage $10.; datalines; Ram24 Albertaa26 Bob85 AB23 ; run;
Show us the code you have already tried.
Do you want the extracted age to be character or numeric?
Are you being forced to use the tools you mentioned? They're not the best ones for the job. Using those only might force you to assume that the age is always two digits long.
I want age in numeric, yes only for this scenario age is only two digit long.
length() is not needed and actually dangerous (think of kids and centenarians).
Use anydigit() to find the first occurence of a digit, and substr() from there.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.