BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
animesh123
Obsidian | Level 7

If I have

Name:

Jack784Jill

Animesh56Mardi

Len7lenove

acer789542aspire

and wanted to extract 1st and last name only using scan and compress function 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Sounds like homework.

 

SCAN(stringcount <, 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.

View solution in original post

4 REPLIES 4
ballardw
Super User

As a minimum you should indicate which part of those values is Last name and which is a first name.

 

 

animesh123
Obsidian | Level 7
So as in example
1st_str
Jack
Animesh
Len
Acer

2nd_str
Jill
Mardi
Lenove
ballardw
Super User

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

 

Patrick
Opal | Level 21

Sounds like homework.

 

SCAN(stringcount <, 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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 664 views
  • 2 likes
  • 3 in conversation