BookmarkSubscribeRSS Feed
GN0001
Barite | Level 11

Hello team,

 

Would you please let me know what these two scan function do with space as a delimiter?

 

FirstName = Scan(MemberName, 1, " ");

LastName = Scan(MemberLast, 2, " ");

 

Regards,

Blue

 

 

Blue Blue
3 REPLIES 3
ballardw
Super User

Without example values for Membername or Memberlast which should I guess.

 

"result" can be interesting depending on other characters in the variable and which position.

 

Give me actual values I can tell you. But I'm not going to guess because there are way too many possible results from missing to equal to the variable depending on the actual values that it isn't worth trying to list all of them.

 

Plus depending on the character encoding you might actually need Kscan.

Tom
Super User Tom
Super User

The two assignment statements are both asking SAS to parse the value of the variable pass to them into "words" based on considering blanks as the delimiter between the words.

 

The first one is taking the first word it finds.

The second one is taking the second word it finds.

 

Also the two assignment statements are taking the words from two DIFFERENT variables.  

The first one is reading from the variable MEMBERNAME and the second one is reading from the variable MEMBERLAST.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1205 views
  • 1 like
  • 4 in conversation