Hey Allin,

this gave some intuition into the problem and I solved it.

Thank you again! ;-)

Cheers,
Artur

2012/6/13 Allin Cottrell <cottrell@wfu.edu>
On Wed, 13 Jun 2012, artur tarassow wrote:

> thanks for replying. But it is not exactly what I need. In your example
> 'sprintf astr$i "%s", varname(i)' generates a string with the name of a
> variable with the ID 'i' from the loaded dataset. But I need a string with
> the name of the i'th variable in a list.
> For example, the following returns a string containing the names of the
> variables in the list in each round, but I need in the first round the name
> of the first variable in ttt, in the second round the name of the second
> variable in ttt and so on...
>
> <hansl>
> list ttt = LRM LRY
> scalar vars = nelem(ttt)
> loop i=1..vars
>    print "$i"
>    sprintf astr$i "%s", varname(ttt)
>    printf "%s\n", astr$i
> endloop
> <hansl>

Then:

<hansl>
open denmark.gdt -q
list ttt = LRM LRY
string vname
loop foreach i ttt -q
    sprintf vname "astr%d", i
    string @vname = "$i"
    print @vname
endloop
</hansl>

Now you have astr1 = "LRM", astr2 = "LRY".

Allin
_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users