Thanks Allin, it works perfectly.

Un abrazo
Leandro


2013/1/22 Allin Cottrell <cottrell@wfu.edu>
On Tue, 22 Jan 2013, Leandro Zipitria wrote:

> I have two quick problems:
>
> 1) I have a database which have monthly data. I want to compact the data
> restricting the original database.
> In doing so, I have made the following loop:
>
> loop i=2002..2012 --progressive
>    loop j=1..12 --progressive
>        smpl Destino=1 && Familia=2 && Anio=i && Mes=j --restrict
>        M[132+(i-2002)*12+j,2]=nobs(Anio)
>        smpl full
>    endloop
> endloop

(By the way, why use --progressive here?)

> which store each sample in a matrix.
>
> The problem is that sometimes the result from the
> restriction is null. In that case, the loop breaks and stop
> running. I know that I have to use the if command, but I do
> not how. What I want to do is that if the result of the
> restriction is null, then to store a N/A, and continue the
> loop.

In the inner portion of the loop:

series cond = Destino==1 && Familia==2 && Anio==i && Mes==j
if sum(cond==1) > 0
   smpl cond --restrict
   M[row,2]=nobs(Anio)
   smpl full
else
   M[row,2]=NA
endif

> 2) The second point I want to know is if there is a chance to put "labels",
> strings should be the right word, in the first row of the matrix.

Strings cannot be part of the matrix itself, but you can add
column heads using the colnames() function.

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