I need a way to remove the middle names from my full name in SAS.
Example: Name= MARY ANN SMITH Name= JERRY J SMITH
Output wanted: Name2= MARY SMITH Name2= JERRY SMITH
Any ideas how I can do this?
CodePudding user response:
If you have actual names of real people then the problem is much harder than you implied. Some people have first or last (or both) names that are more than one word. What about people that only have one name?
Anyway SCAN() can do what you want.
name2=catx(' ',scan(name,1,' '),scan(name,-1,' '));