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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 549 views
  • 2 likes
  • 3 in conversation