I am working on firm level heterogeneity in India and my database has information on firms, codes of the products that the firms are producing in each year and the sales variables for each of the product code by year. I want to generate two variables viz. Intensive and Extensive margin for each firm-year observation. The definitions of each of these two variables are as follows:
Thank you so much.
- Intensive Margin = sum of sales of those products that a firm produce in both periods t and t-1.
- Extensive Margin = sum of sales of those products that a firm produce in year t or in year t-1, but not in both the periods.
Thank you so much.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long company double products_product_code int yr float dsales 14 2.10611020109e+19 1991 274.9848 14 2.1061215e+19 1991 4.6154695 14 2.106e+19 1991 29.39325 14 2.1061109e+19 1991 35.952076 14 2.1061215e+19 1992 11.147906 14 2.10611020109e+19 1992 373.0567 14 2.1061109e+19 1992 41.00837 14 2.106e+19 1992 77.03999 228 1.8010503e+19 1990 0 228 1.41602069999e+19 1990 322.537 228 1.41602030404e+19 1990 0 228 1.000e+20 1990 170.6014 228 1.41602030404e+19 1991 0 228 1.8010503e+19 1991 0 228 1.41602069999e+19 1991 0 228 1.000e+20 1991 291.96457 228 1.41602069999e+19 1992 166.5394 228 1.000e+20 1992 271.90756 228 1.8010503e+19 1992 0 228 1.41602030404e+19 1992 0 289 2.101011648e+19 1990 4.985451 289 2.103060101e+19 1990 1791.2013 289 2.101011648e+19 1991 4.349279 289 2.103060101e+19 1991 1394.089 520 5.110501e+18 1991 12.790994 520 6.070e+18 1991 0 520 2.10101162e+19 1991 216.28407 520 5.1106e+18 1991 0 520 1.000e+20 1991 65.893 520 5.110501e+18 1992 94.1451 520 5.1105e+18 1992 3.417245 520 2.10101162e+19 1992 29.55917 520 1.000e+20 1992 2.2212093 520 6.070e+18 1992 2.0503469 569 1.414050609e+19 1989 3.539676 569 1.414050609e+19 1990 3.612735 569 1.414050609e+19 1991 .18513922 569 1.414050609e+19 1992 1.9216082 572 1.4140501e+19 1989 0 572 1.414051e+19 1989 34.044724 572 1.4140513e+19 1989 0 572 1.4140514e+19 1989 0 572 1.4140599e+19 1989 51.06709 572 2.101011648e+19 1989 75.94592 572 1.414051702e+19 1989 106.71712 572 1.9100107e+19 1989 51.06709 572 1.4140102e+19 1989 818.3828 572 1.3010603e+19 1989 19.313833 572 1.301030201e+19 1989 5.23765 572 1.4140506e+19 1989 0 572 1.4140506e+19 1990 0 572 1.9100107e+19 1990 176.52036 572 1.4140501e+19 1990 0 572 1.414051e+19 1990 0 572 1.301030201e+19 1990 32.011463 572 1.3010603e+19 1990 51.52321 572 1.4140513e+19 1990 0 572 1.4140102e+19 1990 1888.6764 572 1.4140599e+19 1990 57.62064 572 2.101011648e+19 1990 146.64299 572 1.4140514e+19 1990 0 572 1.414051702e+19 1990 265.54272 572 1.3010603e+19 1991 128.97295 572 1.4140514e+19 1991 0 572 1.4140513e+19 1991 0 572 2.101011648e+19 1991 110.8317 572 1.4140102e+19 1991 1455.2684 572 1.4140501e+19 1991 0 572 1.9100107e+19 1991 291.11038 572 1.301030201e+19 1991 53.00647 572 1.414051702e+19 1991 219.96266 572 1.414051e+19 1991 0 572 1.4140506e+19 1991 0 572 1.301030201e+19 1992 39.39966 572 2.101011648e+19 1992 87.9105 572 1.4140506e+19 1992 0 572 1.414051e+19 1992 161.5386 572 1.3010603e+19 1992 91.85046 572 1.4140514e+19 1992 0 572 1.9100107e+19 1992 216.69815 572 1.4140102e+19 1992 1455.325 572 1.414051702e+19 1992 219.40688 572 1.4140513e+19 1992 0 572 1.4140501e+19 1992 0 867 2.101011648e+19 1990 0 867 2.10101161608e+19 1990 0 867 2.10101161604e+19 1990 0 867 1.000e+20 1990 0 867 2.101011648e+19 1992 0 867 2.100e+19 1992 34.973297 867 2.10101161604e+19 1992 0 906 1.00105021e+19 1990 0 906 1.41608e+19 1990 92.12475 906 1.41606e+19 1990 24.486317 906 2.10101160404e+19 1990 9.433253 906 1.41608e+19 1991 100.16032 906 1.00105021e+19 1991 0 906 1.41606e+19 1991 19.43962 906 2.10101160404e+19 1991 5.554177 906 1.41608e+19 1992 116.7377 end
Comment