Partially renaming series names

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

remuct
Posts: 27
Joined: Fri May 12, 2017 6:47 am

Partially renaming series names

Postby remuct » Tue Jul 13, 2021 3:44 pm

Hello,
I have many series whose names include one or more underscore(s) and I wish to rename all characters following the last underscore by a given letter, say 'p'. For example, the following series
us_gdp_u1
uk_interest_rate_xy3
can_w

must be renamed as:
us_gdp_p
uk_interest_rate_p
can_p

Is there an easy way to do this?
Thank you
Best regards

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

Re: Partially renaming series names

Postby EViews Gareth » Tue Jul 13, 2021 4:00 pm

Code: Select all

%serlist = @wlookup("*", "series")

for %j {%serlist}
   !pos_ = @rinstr(%j, "_")
   %newname = @left(%j, !pos_) + "p"
   rename {%j} {%newname}
next
Follow us on Twitter @IHSEViews

remuct
Posts: 27
Joined: Fri May 12, 2017 6:47 am

Re: Partially renaming series names

Postby remuct » Tue Jul 13, 2021 5:00 pm

This is amazing Gareth, thanks !


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 15 guests