Page 1 of 1

@right error

Posted: Thu Feb 09, 2023 8:41 am
by BT454
Good morning!
I'm trying to determine capture the right most character from a temporary string, that is a list of the members of a group. However, the code either crashes with a syntax error if I put brackets around the code name as below

Code: Select all

group g_max hsddcus_* %max = g_max.@members %max = @replace(%max,"_"," ") %test = @right({%max},1)
or returns nothing, if I do not use brackets, as below

Code: Select all

group g_max hsddcus_* %max = g_max.@members %max = @replace(%max,"_"," ") %test = @right(%max,1)
Any thoughts on what I'm doing wrong?
As always thank you very much! The fantastic help and customer support is greatly appreciated!
Bob

Re: @right error

Posted: Thu Feb 09, 2023 8:59 am
by EViews Gareth
The @right function requires the first argument to be a string, so using {%max} is wrong.
The second syntax (without the {}) is correct.

The reason that you end up with an empty string is that the last character of %max is a space. If you add an @trim to the program it should work.

Code: Select all

group g_max hsddcus_* %max = g_max.@members %max = @replace(%max,"_"," ") %max = @trim(%max) %test = @right(%max,1)

Re: @right error

Posted: Thu Feb 09, 2023 9:16 am
by BT454
Thank you sir!