Yes :-)
Very nice trick
Thanks
Giuseppe
On Thu, 2013-11-21 at 15:13 +0100, Riccardo (Jack) Lucchetti wrote:
On Thu, 21 Nov 2013, Giuseppe Vittucci wrote:
> Hi,
>
> I have firm level data and two categorical variables (region and
> sector).
> I need to define another variable which is an index identifying the
> unique combinations region-sector each firm belongs to, so I can use it
> in computing cluster-robust s.e.
>
> One way to do this is to use the command "values" for region and sector
> and then use a nested loop, but this seems quite time-consuming...
>
> Is there a simpler way in gretl to do it?
You mean, like this?
<hansl>
nulldata 1024
# simulated data
region = randgen(i,1,20)
sector = randgen(i,10,99)
# ----------------------------------------------
scalar ndigits = floor(log10(max(sector)))
series unique = region * 10^(ndigits+1) + sector
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------
_______________________________________________ Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users