# How to index the individual ID for a panel data

Hi guys, I am new to Gauss, now i am dealing with a panel data, including 19000 observations and 6000 individuals, which means for each individual, I might have several observations for her. In this case, how can I index each individual from 1 to 6000? Hope I can get an answer here.

0

You can use the GAUSS selif (select if) command to select rows that meet a specific criteria. For example:

``````//Column 1 is member index
//Column 2 is variable 1
//Column 3 is variable 2
x = {  4   -1.18    0,
2   0.667    1,
4   0.768    1,
2   0.607    0,
3  0.0892    0,
3  -0.774    0,
2   -1.79    0,
2   0.483    0,
4   0.817    0,
4  -0.277    1 };

//Assign all observations from the
//individual with id == 4 to 'individual_4'
individual_4 = selif(x, x[.,1] .== 4);

print individual_4;``````

will return:

```4.0000000       -1.1800000        0.0000000
4.0000000       0.76800000        1.0000000
4.0000000       0.81700000        0.0000000
4.0000000      -0.27700000        1.0000000
```

You can use the indexcat command to return just the row number of the observations meeting a criteria. For example:

``````//Column 1 is member index
//Column 2 is variable 1
//Column 3 is variable 2
x = {  4   -1.18    0,
2   0.667    1,
4   0.768    1,
2   0.607    0,
3  0.0892    0,
3  -0.774    0,
2   -1.79    0,
2   0.483    0,
4   0.817    0,
4  -0.277    1 };

//Return indices of locations
//where first column of 'x'
//is equal to 4
idx_4 = indexcat(x[.,1], 4);

print idx_4;``````

will return:

```1.0000000
3.0000000
9.0000000
10.000000
```

Alternatively, you can use the GAUSS function, delif (delete if) to return every observation that does NOT meet a certain criteria (the opposite of selif. For example:

``````//Column 1 is member index
//Column 2 is variable 1
//Column 3 is variable 2
x = {  4   -1.18    0,
2   0.667    1,
4   0.768    1,
2   0.607    0,
3  0.0892    0,
3  -0.774    0,
2   -1.79    0,
2   0.483    0,
4   0.817    0,
4  -0.277    1 };

//Assign all observations from the
//individual with id != 4 to 'not_4'
not_4 = delif(x, x[.,1] .== 4);

print not_4;``````

will return:

```2.0000000       0.66700000        1.0000000
2.0000000       0.60700000        0.0000000
3.0000000      0.089200000        0.0000000
3.0000000      -0.77400000        0.0000000
2.0000000       -1.7900000        0.0000000
2.0000000       0.48300000        0.0000000
```

aptech

1,773

0

You can use the GAUSS selif (select if) command to select rows that meet a specific criteria. For example:

``````//Column 1 is member index
//Column 2 is variable 1
//Column 3 is variable 2
x = {  4   -1.18    0,
2   0.667    1,
4   0.768    1,
2   0.607    0,
3  0.0892    0,
3  -0.774    0,
2   -1.79    0,
2   0.483    0,
4   0.817    0,
4  -0.277    1 };

//Assign all observations from the
//individual with id == 4 to 'individual_4'
individual_4 = selif(x, x[.,1] .== 4);

print individual_4;``````

will return:

```4.0000000       -1.1800000        0.0000000
4.0000000       0.76800000        1.0000000
4.0000000       0.81700000        0.0000000
4.0000000      -0.27700000        1.0000000
```

You can use the indexcat command to return just the row number of the observations meeting a criteria. For example:

``````//Column 1 is member index
//Column 2 is variable 1
//Column 3 is variable 2
x = {  4   -1.18    0,
2   0.667    1,
4   0.768    1,
2   0.607    0,
3  0.0892    0,
3  -0.774    0,
2   -1.79    0,
2   0.483    0,
4   0.817    0,
4  -0.277    1 };

//Return indices of locations
//where first column of 'x'
//is equal to 4
idx_4 = indexcat(x[.,1], 4);

print idx_4;``````

will return:

```1.0000000
3.0000000
9.0000000
10.000000
```

Alternatively, you can use the GAUSS function, delif (delete if) to return every observation that does NOT meet a certain criteria (the opposite of selif. For example:

``````//Column 1 is member index
//Column 2 is variable 1
//Column 3 is variable 2
x = {  4   -1.18    0,
2   0.667    1,
4   0.768    1,
2   0.607    0,
3  0.0892    0,
3  -0.774    0,
2   -1.79    0,
2   0.483    0,
4   0.817    0,
4  -0.277    1 };

//Assign all observations from the
//individual with id != 4 to 'not_4'
not_4 = delif(x, x[.,1] .== 4);

print not_4;``````

will return:

```2.0000000       0.66700000        1.0000000
2.0000000       0.60700000        0.0000000
3.0000000      0.089200000        0.0000000
3.0000000      -0.77400000        0.0000000
2.0000000       -1.7900000        0.0000000
2.0000000       0.48300000        0.0000000
```

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.