Hi Dear All.
I'm looking to use sas functions ( not re) to find strings in a plain text.
the text is like this :
data have:
some text blabla, bla right home num8, left home num7 bla bla bla
data want:
the variables left home and right home have the respectives values of num8 nad num7
conditions :
1) the numbers allowed are 0-8
2) the separator between right home with num and the left home and num could be
a space
, ( comma)
.period
'and' word
3) blanks between string num and 0-8 numbers should be removed , sometimes the text could be like right home num 8 ( a space between num and 😎
if there is no right home with num0-8 or left home with num0-8 found write in the respective variables 'not found'.
Thanks for your response.
Your Source data and Desired Output is not pretty clear, please give information clearly.
Thank you for the message, here are the images and examples:
data have;
texto='some text blablasome text blablasome text blabla
some text blabla, bla right home num8, left home num7 bla bla bla
some text blabla
some text blabla etc ..';
data want;
set have;
if findw(texto,"right home num8","i")>0 then rh = "num8";
else if find(texto,"left home num7","i")>0 then lh = "num7";
run;
result:
rh =
lh= num7
Thanks
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: