Page 1 of 1

Manipulating alpha series

Posted: Tue Jun 22, 2010 8:07 am
by javiersan
Hi,

I have an alpha series contaning date strings which has a mixe of formats and Eviews is unable to read it as a date identifier. Some of the date formats are dd/mm/yyyy and some are yyyy-dd-mm. I want to convert the ones with format yyyy-dd-mm to dd/mm/yyyy.

I have done something like:

Code: Select all

alpha temp=@wreplace(date,"*-*","*##*") series date_len=@len(temp) alpha date_mod=@mid(date,6,2)+"/"+@right(date,2)+"/"+@left(date,4) alpha date_ok=@recode(date_len>10,date_mod,date)
where date_ok has the alpha series with the appropriate format but the codes is a bit convoluted. Do you have any ideas for a better code?

Thanks,

Javier

Re: Manipulating alpha series

Posted: Tue Jun 22, 2010 8:23 am
by EViews Gareth

Code: Select all

alpha date_ok = @datestr(@recode(@instr(date,"/")=3,@dateval(date,"dd/mm/yyyy"), @dateval(date,"yyyy-mm-dd")),"dd/mm/yyyy")

Re: Manipulating alpha series

Posted: Tue Jun 22, 2010 8:45 am
by javiersan
Thanks!

Re: Manipulating alpha series

Posted: Tue Jun 22, 2010 9:02 am
by EViews Gareth
If the months aren't formatted to be two digits rather than one (i.e. March is just 3, not 03), then you could change the code to be:

Code: Select all

alpha date_ok = @datestr(@recode(@instr(date,"/")>0,@dateval(date,"dd/mm/yyyy"), @dateval(date,"yyyy-mm-dd")),"dd/mm/yyyy")