SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

How to separate charaters and numerics by using Data FLux

Reply
Frequent Contributor
Posts: 140

How to separate charaters and numerics by using Data FLux

Hi

i am having data

string='erer4556l78poo9'

i want chat in one column and num in another column

string_Num=4556789

string_char='ererlpoo'

Super User
Posts: 10,020

Re: How to separate charaters and numerics by using Data FLux

Posted in reply to sas_Forum

Can you make a function in DataFlux, I never used it  before.

string_Num=compress(string,,'kd');

string_char=compress(string,,'d');

SAS Employee
Posts: 85

Re: How to separate charaters and numerics by using Data FLux

Posted in reply to sas_Forum

Here is a solution which will loop through the whole input string and pick the values that are numeric or characters and assign them to a temp variable until the end of the loop. Also see attached:parsing_02APR15.png

Pre-Processing Expression:

hidden string temp_string_num

real string_Num

hidden string temp_string_char

string string_char

hidden integer cnt

hidden integer i

string_Num = 0

temp_string_num = ''

temp_string_char = ''

string_char = ''

cnt = 0

i = 0

Expression:

cnt = len(`input_string`)

  while i <= cnt

begin

  if isnumber(mid(`input_string`, i, 1)) == true

  temp_string_num = temp_string_num & mid(`input_string`, i, 1)

  else

  temp_string_char = temp_string_char & mid(`input_string`, i, 1)

  i = i + 1

end

i = 0

string_num = temp_string_num

string_char = temp_string_char

Ask a Question
Discussion stats
  • 2 replies
  • 268 views
  • 3 likes
  • 3 in conversation