@right error

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

BT454
Posts: 139
Joined: Wed Aug 02, 2017 6:07 am

@right error

Postby BT454 » Thu Feb 09, 2023 8:41 am

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

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

Re: @right error

Postby EViews Gareth » Thu Feb 09, 2023 8:59 am

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)

BT454
Posts: 139
Joined: Wed Aug 02, 2017 6:07 am

Re: @right error

Postby BT454 » Thu Feb 09, 2023 9:16 am

Thank you sir!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests