On Fri, 27 Sep 2019, Artur Tarassow wrote:
Am 27.09.19 um 13:08 schrieb ΑΝΔΡΕΑΣ ΖΕΡΒΑΣ:
> Just a quick question: suppose that one has several files with time series,
> e.g. several files with macro data, each file for a country (or maybe one
> file with time series from several countries). Is there a way to create from
> hansl a panel dataset, without copying (stacking) the data into a
almost everyhting can be done with gretl ;-)
You will need the join command for this type of work. See ch. 7 in
"join" is not the only tool that could be used for this job but I
think Artur is right: it should work well. Here's a little example, in
the form of two scripts (which could be combined). The first reads
some series from dbnomics -- annual population and employment for
Germany, France and Italy -- and writes a time-series dataset; the
second creates a panel dataset and fills it using "join", drawing from
the time-series data.
# script 1: create time-series dataset
set verbose off
setobs 1 1980
provider = "IMF"
database = "WEO"
bundle spec = null
spec["weo-country"] = defarray("FRA", "DEU",
spec["weo-subject"] = defarray("LP", "LE")
bs = dbnomics_get_multiple(provider, database, 20, 0, spec)
list X = null
loop i = 1..nelem(bs) --quiet
sn = fixname(bs[i].series_code, 1)
series tmp = NA
# add series to list
X += genseries(sn, tmp)
# save the per-country time-series data
store tmp.gdt X
# script 2: convert to panel
# 38 years, 3 countries
NT = 38 * 3
setobs 38 1:01 --stacked-time-series
series country = $unit
strings cnames = defarray("DEU", "FRA", "ITA")
# set the sample to each country in turn
loop i = 1..3 --quiet
smpl country == i --restrict --replace
ename = sprintf("%s_LE", cnames[i])
pname = sprintf("%s_LP", cnames[i])
join tmp.gdt Employment --data="@ename"
join tmp.gdt Population --data="@pname"
setinfo Employment --description="Employment - Persons"
setinfo Population --description="Population - Persons"