Hello,
I have a dataset of 1000 firms (id_firm) over 10 years (year). Each year, a firm produces a single 2-digit output (idmain2_out) using several 2-digit inputs (id2_in), so that each observation is described by id_firm year idmain2_out id2_in as is shown below:
It follows that every year, to produce each output (year idmain2_out), a group of inputs (id2_in) is used; and firms that produce an output use some of those inputs and some others not. For example, in 1990 idmain2_out={44} was produced using id2_in = {01, 02, 06}; firm 1 used id2_in = {01, 02} to produce idmain2_out={44}, while firm 3 used id2_in={02, 06} to do it.
By id_firm year idmain2_out, I want to create(expand) new observations so that it shows all the inputs that were used by all firms that produced that output that year, along with an indicator variable (use) which takes the value 1 if the firm used that input and 0 if the firm didn't use that input. The new dataset should look the following way
I haven't figured out a way to do this so I appreciate your help very much. (I also want to know how to create appropriate lists of observations in the forum
)
Best,
Gustavo
I have a dataset of 1000 firms (id_firm) over 10 years (year). Each year, a firm produces a single 2-digit output (idmain2_out) using several 2-digit inputs (id2_in), so that each observation is described by id_firm year idmain2_out id2_in as is shown below:
Code:
id_firm year idmain2_out id2_in 1 1990 44 01 1 1990 44 02 1 1991 50 20 ... 2 1990 28 33 ... 3 1990 44 01 3 1990 44 06
By id_firm year idmain2_out, I want to create(expand) new observations so that it shows all the inputs that were used by all firms that produced that output that year, along with an indicator variable (use) which takes the value 1 if the firm used that input and 0 if the firm didn't use that input. The new dataset should look the following way
Code:
id_firm year idmain2_out id2_in use 1 1990 44 01 1 1 1990 44 02 1 1 1990 44 06 0 1 1991 50 20 1 ... 2 1990 28 33 1 ... 3 1990 44 01 1 3 1990 44 02 0 3 1990 44 06 1
) Best,
Gustavo

Comment