I have a data set that has a subject variable. This is based on email subjects.
The issue I'm having is that I have to find a specific string within this variable but the string isn't consistent. The string 'Inquiry#' is what i'm looking for but it has to have 1 or 2 numbers following it. For ex Inquiry#1 or Inquiry#12.
I need the string before and after this string. I have done this so far but I feel I could have done it much cleaner.
data inq_2 ;
set inq ;
subject_ = compress(subject) ;
inq_pos = find(subject_ , 'Inquiry#', 'i') ;
inq_str = substr(subject_ , inq_pos) ;
inq_dash_pos = find(inq_str, '-') ; /*A dash does not always follow. Needs fix */
if inq_pos = 1 then x = substr(subject_ , inq_dash_pos) ;
else x = substr(subject_,1,inq_pos -1) || ' ' || substr(subject_, (inq_pos + inq_dash_pos) - 1) ;
run ;
Thanks for any help
... View more