This works fine, Ignacio! Thanks for your help! Artur
2012/5/22 Ignacio Diaz-Emparanza <ignacio.diaz-emparanza(a)ehu.es> > Artur: > > I think this is a problem with the way in that 'loop foreach' treats > its arguments: probably first if they are two or more arguments all of > them are treated as strings, for a unique argument it checks if it is a > list or a string and act different in each case. A solution may be: > > open denmark > list ttt1 = LRM IBO > list ttt2 = IDE LRY > > loop j=1..2 > list x=ttt$j > loop foreach i x > sprintf astr "%11s", "$i" > print astr > endloop > endloop > > > > > On 22/05/12 16:09, artur tarassow wrote: > > Dear gretl mailing list, > > > > I want to generate strings containing the names of the variables within > > the respective list. For an individual list it works properly: > > > > <hansl> > > open denmark > > list ttt = LRM IBO > > > > loop foreach i ttt > > sprintf astr "%11s", "$i" > > print astr > > endloop > > <hansl> > > > > > > But for a loop over different lists, it does not work as I want it to. > > > > <hansl> > > list ttt1 = LRM IBO > > list ttt2 = IDE LRY > > > > loop j=1..2 > > loop foreach i ttt$j > > sprintf astr "%11s", "$i" > > print astr > > endloop > > endloop > > <hansl> > > > > I can't find the problem. Does anyone know a solution? > > > > Best, > > Artur > > > > > > _______________________________________________ > > Gretl-users mailing list > > Gretl-users(a)lists.wfu.edu > > http://lists.wfu.edu/mailman/listinfo/gretl-users > > > -- > Ignacio Diaz-Emparanza > DEPARTAMENTO DE ECONOMÍA APLICADA III (ECONOMETRÍA Y ESTADÍSTICA) > UPV/EHU Avda. Lehendakari Aguirre, 83 | 48015 BILBAO > T.: +34 946013732 | F.: +34 946013754 > www.ehu.es/ignacio.diaz-emparanza/ > www.ea3.ehu.es > > > > > _______________________________________________ > Gretl-users mailing list > Gretl-users(a)lists.wfu.edu > http://lists.wfu.edu/mailman/listinfo/gretl-users >
This works fine, Ignacio! Thanks for your help!
Artur
2012/5/22 Ignacio Diaz-Emparanza <ignacio.diaz-empara...@ehu.es>
Artur
2012/5/22 Ignacio Diaz-Emparanza <ignacio.diaz-empara...@ehu.es>
Artur:
I think this is a problem with the way in that 'loop foreach' treats
its arguments: probably first if they are two or more arguments all of
them are treated as strings, for a unique argument it checks if it is a
list or a string and act different in each case. A solution may be:
open denmark
list ttt1 = LRM IBOlist x=ttt$j
list ttt2 = IDE LRY
loop j=1..2
loop foreach i x
sprintf astr "%11s", "$i"
print astr
endloop
endloop
> _______________________________________________On 22/05/12 16:09, artur tarassow wrote:
> Dear gretl mailing list,
>
> I want to generate strings containing the names of the variables within
> the respective list. For an individual list it works properly:
>
> <hansl>
> open denmark
> list ttt = LRM IBO
>
> loop foreach i ttt
> sprintf astr "%11s", "$i"
> print astr
> endloop
> <hansl>
>
>
> But for a loop over different lists, it does not work as I want it to.
>
> <hansl>
> list ttt1 = LRM IBO
> list ttt2 = IDE LRY
>
> loop j=1..2
> loop foreach i ttt$j
> sprintf astr "%11s", "$i"
> print astr
> endloop
> endloop
> <hansl>
>
> I can't find the problem. Does anyone know a solution?
>
> Best,
> Artur
>
>
> Gretl-users mailing list
> gretl-us...@lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users
--
Ignacio Diaz-Emparanza
DEPARTAMENTO DE ECONOMÍA APLICADA III (ECONOMETRÍA Y ESTADÍSTICA)
UPV/EHU Avda. Lehendakari Aguirre, 83 | 48015 BILBAO
T.: +34 946013732 | F.: +34 946013754
www.ehu.es/ignacio.diaz-emparanza/
www.ea3.ehu.es
_______________________________________________
Gretl-users mailing list
gretl-us...@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users