Page 1 of 1

extract a portion of a string

Posted: Fri Oct 04, 2019 10:30 am
by mark lynch
Hi

I have an alpha series (6 million or so) that I've been trying to split from one series into two where the size of the string varies making @trim difficult


For example, I'm attempting to split the string into two - generate two additional series - one containing all characters up to the space preceding "["

the second containing the string with the []

the number of characters in the strings vary across the dataset

here's a example of a typical string:

Accounting, tax preparation, bookkeeping and payroll services [BS541200]

thanks

Re: extract a portion of a string

Posted: Fri Oct 04, 2019 12:00 pm
by EViews Matt
Hello,

As a starting point, here's an example of creating new alpha series (left and right) by splitting an existing alpha series (orig) on a specific character ("[").

Code: Select all

alpha left = @left(orig, @instr(orig, "[") - 1) alpha right = @mid(orig, @instr(orig, "["))

Re: extract a portion of a string

Posted: Fri Oct 04, 2019 12:41 pm
by mark lynch
big help - thanks