Reshape Worldbank dataset from wide to long

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

binhpham79
Posts: 14
Joined: Fri Apr 27, 2018 12:08 pm

Reshape Worldbank dataset from wide to long

Postby binhpham79 » Tue Jan 31, 2023 12:40 am

Hi Eviews users,

I have a dataset downloaded from the WB like this.

wb_panel_sample.xlsx
(9.95 KiB) Downloaded 102 times


I have tried to reshape to the standard long panel as usual by stacking the _? year columns but I cannot spread the multiple series and their associated values as can be easily done in R.

Please guide me with a suggestion.

Thanks!

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

Re: Reshape Worldbank dataset from wide to long

Postby EViews Gareth » Tue Jan 31, 2023 10:12 am

Code: Select all

close @wf
wfopen wb_panel_sample.xlsx colhead=1
pagestruct(none)
pagestack num? @ *? *
alpha sername = @makevalidname(indicators)
d id01
pageunstack sername var01 iso3
d indicators* sername num
pagestruct @date(var01) iso3
rename num* *
d var01
Follow us on Twitter @IHSEViews

binhpham79
Posts: 14
Joined: Fri Apr 27, 2018 12:08 pm

Re: Reshape Worldbank dataset from wide to long

Postby binhpham79 » Tue Jan 31, 2023 9:23 pm

Thanks, Gareth. It works perfectly! :))


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 12 guests