Page 1 of 1

iterating on elements of series - date in while loop

Posted: Wed Mar 11, 2015 2:28 am
by loulouviews
Hi everybody,

Here is my issue :
I have two series and I need to check whether some elements of the first series are equal to "na" and if it's not the case, copy paste these elems in the second series.
Currently, my code is as follows :

Code: Select all

smpl %debprev %debsemep-1 %date=%debprev while @dtoo(%date) < @dtoo(%debsemep) for %i a1 a2 a3 a4 if @elem({%i}_ct(),%date) <> na then @elem(gm_{%i}f,%date)=@elem({%i}_ct,%date) endif next %date=@otod(@dtoo(%date)+1) wend
I'd like to know if there is any way to make it easier and faster since I need to repete this kind of things for a lot of series.
Thanks a lot !

Loulouviews

Re: iterating on elements of series - date in while loop

Posted: Wed Mar 11, 2015 2:58 am
by trubador

Code: Select all

smpl %debprev %debsemep-1 for %i a1 a2 a3 a4 gm_{%i}f = @recode({%i}_ct<>NA,{%i}_ct,gm_{%i}f) next

Re: iterating on elements of series - date in while loop

Posted: Wed Mar 11, 2015 3:07 am
by loulouviews
Hi @trubador,
Thanks a lot for your idea, I'll try that !

Loulouviews