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
-------------------------------------------------------