If I have
Name:
Jack784Jill
Animesh56Mardi
Len7lenove
acer789542aspire
and wanted to extract 1st and last name only using scan and compress function
Sounds like homework.
SCAN(string, count <, character-list <, modifier>>)
Use d as value for the modifier in scan function to define digits as the word separators, set count to 1 to extract the first word, and to -1 to extract the last word.
As a minimum you should indicate which part of those values is Last name and which is a first name.
Which actually does not clarify which is last name and which is first. Plus you have also changed the case of the string but only for some.
@animesh123 wrote:
So as in example
1st_str
Jack
Animesh
Len
Acer
2nd_str
Jill
Mardi
Lenove
Sounds like homework.
SCAN(string, count <, character-list <, modifier>>)
Use d as value for the modifier in scan function to define digits as the word separators, set count to 1 to extract the first word, and to -1 to extract the last word.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.