BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JNWong
Fluorite | Level 6

As i have used the scan function to parse the string of characters . the modifier used like ' ' , - and so on. i need to parse them furthermore. data like: 

 xcode1130

tmun3340bf

i have no idea about how to parse them ,like this     xcode 1130

                                                                                  tmun 3340 bf  

  the characters didnot contain - . and other modifiers.

 

Thank you!                                                          

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Here is an example, I first pull out the numeric part (using compress keep digitis), then use this to replace in the original string a comma I then use for scan:

data want;
  length theline $100;
  input theline $;  
  numeric_part=compress(theline,"","kd");
  theline=tranwrd(theline,strip(numeric_part),",");
  word1=scan(theline,1,",");
  word2=scan(theline,2,",");
datalines;
 xcode1130
tmun3340bf
;
run;

View solution in original post

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Here is an example, I first pull out the numeric part (using compress keep digitis), then use this to replace in the original string a comma I then use for scan:

data want;
  length theline $100;
  input theline $;  
  numeric_part=compress(theline,"","kd");
  theline=tranwrd(theline,strip(numeric_part),",");
  word1=scan(theline,1,",");
  word2=scan(theline,2,",");
datalines;
 xcode1130
tmun3340bf
;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1 reply
  • 997 views
  • 0 likes
  • 2 in conversation