Am 19.04.2012 17:50, schrieb Allin Cottrell:
On Thu, 19 Apr 2012, Artur Tarassow wrote:
> I've got a defined list and want save the position of a variable in this
> list as a number (in a scalar named 'a') using the command 'inlist';
> which works fine so far.
> In a next step I want to use this scalar for the following restriction,
> which doesn't work:
>
> <hansl>
> open denmark
> list ttt = LRY IBO
> scalar a = inlist(ttt,IBO)
> ols LRM const ttt
>
> restrict
> b[a]=1
> end restrict
> <hansl>
>
> Is there a way to store the position of IBO and use it for this
> restrict-command?
You can use string substitution. But note that your inlist()
call will not do what you want: IBO is at position 2 in the
list ttt, but in position 3 in the regression list. So you
want something like:
<hansl>
open denmark
list ttt = const LRY IBO
string astr
sprintf astr "%d", inlist(ttt,IBO)
ols LRM ttt
restrict
b[@astr]=1
end restrict
</hansl>
Allin Cottrell
Thank you, Allin, that's a nice way to do it. ;)
Artur
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users