Desktop productivity for business analysts and programmers

split numeric and character in 1 column to 2 colums

Reply
Learner
Posts: 1

split numeric and character in 1 column to 2 colums

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

 

Super User
Posts: 7,422

Re: split numeric and character in 1 column to 2 colums

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;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 1 reply
  • 199 views
  • 0 likes
  • 2 in conversation