Hello,

Assume that I have a database that has two columns: id (firm) and group. Based on this, I would like to create dummy variables for each firm that indicates the group that is located. That is, I would like all firms that belong in the same group to have a variable name such as: _Indic_group1_firmID, _Indic_group2_firmID etc. I will provide an example of what I mean by that.

Code:
input id group
1    1
2    1
3    1
4    2
5    2
6    2
7    3
8    3
9    3
10    4
11    4
12    4
end
What I would like to obtain is something like this:
Code:
input id     group    indic1_1    indic1_2    indic1_3    indic2_4    indic2_5    indic2_6    indic3_7    indic3_8    indic3_9    indic4_10    indic4_11    indic4_12
1    1    1    0    0    0    0    0    0    0    0    0    0    0
2    1    0    1    0    0    0    0    0    0    0    0    0    0
3    1    0    0    1    0    0    0    0    0    0    0    0    0
4    2    0    0    0    1    0    0    0    0    0    0    0    0
5    2    0    0    0    0    1    0    0    0    0    0    0    0
6    2    0    0    0    0    0    1    0    0    0    0    0    0
7    3    0    0    0    0    0    0    1    0    0    0    0    0
8    3    0    0    0    0    0    0    0    1    0    0    0    0
9    3    0    0    0    0    0    0    0    0    1    0    0    0
10    4    0    0    0    0    0    0    0    0    0    1    0    0
11    4    0    0    0    0    0    0    0    0    0    0    1    0
12    4    0    0    0    0    0    0    0    0    0    0    0    1
end
As it can be seen from the above, firms with id 1, 2, and 3 belong to the same group (group1), and for this reason the dummy variables have names such as: indic1_1, indic1_2, indic1_3. In the same manner, firms with id 10, 11, and 12 belong to the fourth group and have dummy names: indic4_10, indic4_11, indic4_12.

I wonder if it's possible to achieve this.

Thanks in advance.