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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 911 views
  • 3 likes
  • 3 in conversation