extract a portion of a string

For requesting general information about EViews, sharing your own tips and tricks, and information on EViews training or guides.

Moderators: EViews Gareth, EViews Moderator

mark lynch
Posts: 10
Joined: Tue Jul 16, 2019 10:37 am

extract a portion of a string

Postby mark lynch » Fri Oct 04, 2019 10:30 am

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

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: extract a portion of a string

Postby EViews Matt » Fri Oct 04, 2019 12:00 pm

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, "["))

mark lynch
Posts: 10
Joined: Tue Jul 16, 2019 10:37 am

Re: extract a portion of a string

Postby mark lynch » Fri Oct 04, 2019 12:41 pm

big help - thanks


Return to “General Information and Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 9 guests