Dear Allin,
Thank you!
It was not my question, but I
was interested: I mostly use neat data files
that come with Gretl, but some exercises
are based on local country data. Naturally,
I am lazy to copy-past labels (not to say
on typing). This possibility is excellent.
Furthermore, on labeling Mihai's xls, I
have learned how to find/replace line
breaks, etc. in LibreOffice.
Oleh
5 січня 2016, 18:44:25, від "Allin Cottrell" <cottrell(a)wfu.edu>:
On Tue, 5 Jan 2016, cociuba mihai wrote:
> [W]hen trying to run the script from
>
http://lists.wfu.edu/pipermail/gretl-users/2014-January/009553.html in
> order to set the description to the variables I receive the following error:
> #########
> ? string line
> ? scalar i = 1
> Generated scalar i = 1
> ? loop while getline(D, line) -q
>> setinfo i --description="@line"
>> i++
>> endloop
> Command has insufficient arguments
>>> setinfo i --description="@line"
> ##########
> Any ideas of what seems to be problem?
Ah, the example you cite dates from January 2014, and since then we
have made substantial changes to the gretl command interpreter. You're
right, the particular phrasing of that loop no longer works.
Arguably, it was only by a strange hack that it worked in the first
place. The argument to "setinfo" should be the name or ID number of a
series; at the time of writing that script, the scalar variable named
"i" was being read as containing the ID number of a series -- that's
what I'm describing as a strange hack (since in general in gretl
commands you cannot give the name of a scalar where the name of a
series is required).
Anyway, here's a version that will work with current gretl:
open prod.txt
string D = readfile("pnames.txt")
string line
loop i=1..$nvars-1 -q
getline(D, line)
setinfo $i --description="@line"
endloop
labels
Note that here we're using "$i" (string substitution) to get the name
of the series into the "setinfo" command. Here's another variant of
the loop that will work (treating the argument to "setinfo" as a list
with a single member):
loop i=1..$nvars-1 -q
getline(D, line)
list Li = i
setinfo Li --description="@line"
endloop
Allin Cottrell
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users