Reputation:
I have values in a variable that look like:
B1234
A0345
C65405
I want to split it so that it so that it will appear as the first 3 characters followed by everything else as shown below.
B1234: B12 34
A0345: A03 45
C65405: C65 405
Is there any way I can do this in SAS
Thanks!
Upvotes: 0
Views: 1127
Reputation: 27498
Use a WHERE
statement, or an IF
statement
where item_code like 'B1%'
or
if item_code =: 'B1'
There are other ways but you haven't explained the situation in more detail
Upvotes: 0
Reputation: 635
I think the solution suggested by Stu with substr is the easiest, but you can also do it using regexes:
result = prxChange('s/^(.{3})(.*)/$1 $2/', -1, trim(source));
Upvotes: 1
Reputation: 12849
Use substr()
and concatenate them.
data want;
var = 'B1234';
split = catx(' ', substr(var, 1, 3), substr(var, 4) );
run;
Upvotes: 2