BookmarkSubscribeRSS Feed
Bronnewasser
Calcite | Level 5

One column contains numeric and character. I want to split this to two columns.

1234567 - Romana

The number is a registernumber and the name is the name of the registergood.

I want two columns.

Reg.nr.        and        name

1234567                    Romana

 

1 REPLY 1
Kurt_Bremser
Super User

To split the string, use the scan() function, and then you can further process the parts:

data want;
set have;
numvar = input(scan(oldvar,1,'-'),best.);
length namevar $20; * use sufficient length here;
namevar = strip(scan(oldvar,2,'-')); * strip removes blanks;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1886 views
  • 0 likes
  • 2 in conversation