Page 1 of 1

Transforming numerical series into alpha or svector

Posted: Wed Jun 09, 2021 1:48 am
by michel
Dear Support,

I need to convert a numerical series into a string in order to find the unique values in the series. Later in the progam I still need it to be a string.
Currently I use a simple loop to do the transformation:

Code: Select all

%codepays_all ="" for !i = 1 to @obs(codepays) %codepays_all = %codepays_all +" "+@str(codepays(!i)) next string codepays_all = %codepays_all %codepays_unique = @wunique(codepays_all) string codepays_unique = %codepays_unique
However, the series codepays has 160000 observations and the loop takes some minutes to run (I have to run this multiple times for similar variables).

Now my question is, is there a faster way to perform this transformation? Ideally I could convert the series codepays into an svector or alpha and from there on use @wjoin to convert it into a string (such that I can use @wunique).

Kind regards,

michel

Re: Transforming numerical series into alpha or svector

Posted: Wed Jun 09, 2021 6:18 am
by EViews Gareth

Re: Transforming numerical series into alpha or svector

Posted: Wed Jun 09, 2021 9:01 am
by michel
Thank you very much!

Re: Transforming numerical series into alpha or svector

Posted: Wed Jun 09, 2021 9:20 am
by EViews Gareth
Probably a bit faster :D

Re: Transforming numerical series into alpha or svector

Posted: Thu Jun 10, 2021 3:07 am
by michel
Its no comparision. :)
Considering the transformation of a vector into an svector, is there any function I could use? Currently I do it as shown in my first post on the current topic.

Ideally this would work:

Code: Select all

vector codepaysorigine_unique = @uniquevals(codepaysorigine) svector codepaysorigine_unique_sv = @str(codepaysorigine_unique)

Kind regards,

michel

Re: Transforming numerical series into alpha or svector

Posted: Thu Jun 10, 2021 7:29 am
by EViews Gareth
Not currently.