On Fri, 3 May 2019, Fred Engst wrote:
Hi Allin,
Thanks for all the great responses.
Glad you like them. (Apart from my suggestion of limiting te length
of series names to less than 31 characters!)
But I’d rather keep the 31 character name than shorten it.
OK, if some users really want "primary" series names of the maximum
length (or close to it) we'll not snatch away that option.
But there will be some cost. Gretl's standard way of naming
automatically generated "derivative" series (lags, logs, squares,
etc.) involves adding a suitable prefix or suffix. If there are not
enough unused bytes, given the max of 31, we first try truncating
the primary name to free some space. That will work OK if all series
names are unique in their first 31-n bytes, where n is the length of
the prefix or suffix. Otherwise we'll get a name collision (as per
your original example).
So my first piece of advice is: try to ensure that long names are
unique in their first 31-n bytes -- allowing for whatever the
maximal n will be in the context of your work (e.g. if you want
auto-generated lags of logs, n >= 4, as in "l_foo_3").
That said, matters are somewhat improved in git and snapshots. We
now activate a fallback to ensure unique names -- but you might not
like the results! If truncation yields identical names we truncate
further and append a guaranteed unique 3-letter sequence (well, from
"aaa" to "ZZZ", and so guaranteed to handle up to 52^3 = 140608 name
collisions).
There is another option: take charge of naming derivative series
yourself. There's an example script below. In the case of data9-7,
with its short series names, it's clearly not necessary, but the
script is just illustrative.
<hansl>
open data9-7
list L = QNC PRIME
list Lags = null
scalar p = 3
loop foreach i L --quiet
loop j=1..p --quiet
# for lags see the note below
Lags += genseries(sprintf("var%d_%d", i, j), "$i(-$j)")
endloop
endloop
list Lags print
print QNC Lags --range=1:5 --byobs
list Logs = null
loop foreach i L --quiet
Logs += genseries(sprintf("log_var_%d", i), log($i))
endloop
print Logs --range=1:5 --byobs
</hansl>
note: In creating lags via genseries() it's necessary to protect the
"varname(-lag)" syntax by quotation in gretl 2019a and earlier, but
with current git/snapshots that has been relaxed: the line
Lags += genseries(sprintf("var%d_%d", i, j), $i(-$j))
could be substituted.
Allin