BookmarkSubscribeRSS Feed
sas_Forum
Calcite | Level 5

Hi

i am having data

string='erer4556l78poo9'

i want chat in one column and num in another column

string_Num=4556789

string_char='ererlpoo'

2 REPLIES 2
Ksharp
Super User

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

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

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

skillman
SAS Employee

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 956 views
  • 3 likes
  • 3 in conversation