extacting portions of a string

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

mark
Posts: 37
Joined: Thu Mar 12, 2009 3:27 pm

extacting portions of a string

Postby mark » Thu Apr 08, 2010 9:40 am

Hi
Working with irregular dated data - strings are "MM/dd?yyyyy"
Id like to etract "MM/YYYYY"
I have 60,000 observations - is there a function that will do the trick?
thanks

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: extacting portions of a string

Postby EViews Gareth » Thu Apr 08, 2010 9:57 am

You can do it easily with string manipulation:

Code: Select all

alpha mydate = @left(date,3) + @right(date,4)


You can also get a bit more clever and use the date functions:

Code: Select all

alpha mydate = @datestr(@dateval(date,"MM/DD/YYYY"),"MM/YYYY")


Where you're using @dateval to convert your date strings into an EViews date, then you're using the @datestr function to convert it back into a string, but with the "MM/YYYY" format.
Follow us on Twitter @IHSEViews


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 27 guests