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
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
I wonder if it's possible to achieve this.
Thanks in advance.
0 Response to Generating dummy variables whose name indicates the group they belong
Post a Comment