Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Imports from particular set of industries from a group

    Hi!

    I am trying to create a new variable that shows initially the total imports from industrialized countries (ImportsIndustrialized) in a particular set of industries (tech_intensity=3) and later I want to calculate the share of imports in this set of industries over total imports from this country.

    For the second variable (total imports by country), it is relatively straightforward:

    Code:
     bysort country year: egen totalimp_country= total(ImportsWorld) (Total Imports from world to country j)
    However, the first variable (imports from industrialized country in tech_intensity=3 ) is obscure. Any potential hint? Thank you very much!

    Code:
     * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int country str5 isic int year float tech_intensity long(ImportsWorld ImportsIndustrialized ImportsDeveloping)
    840 "2412" 2004 3  4776058  4138682   637376
    840 "2695" 1998 2   738238   365615   372623
    840 "2222" 1997 1    16994    15397     1598
    840 "2692" 2002 2   318894   240967    77925
    124 "3230" 1999 3  3567059  2500915  1024937
    840 "2413" 2000 3  7087912  6350475   737434
    124 "2921" 2000 3  1524103  1513799    10280
    840 "2891" 1999 2        .        .        .
    124 "2320" 1990 2   266506   262635     2199
    840 "2927" 1999 3   772252   663830   108280
    124 "2811" 2001 2   332652   320198    12453
    124 "2520" 1992 2  2047710  1968607    77872
    840 "2732" 1997 2        .        .        .
    840 "2912" 2006 3 21609499 13715370  7894115
    124 "2912" 1994 3  2422482  2372000    45490
    124 "1541" 1992 1   241446   238165     3266
    840 "2811" 2006 2  3828246  2580381  1247852
    840 "3120" 2001 3  9413025  5124107  4288915
    124 "2893" 1990 2  1124887  1035857    31488
    840 "2891" 2004 2        .        .        .
    124 "3312" 1993 3  1448583  1418931    16560
    840 "1531" 2002 1   748992   512212   236382
    840 "3430" 2008 3 49603586 30928537 18674680
    124 "2699" 1996 2   334201   324543     9359
    124 "1553" 1990 1    54434    45815     4568
    124 "2922" 2000 3  2388628  2282403   106184
    840 "2899" 2001 2 10747537  6387743  4359359
    124 "2022" 2000 1   154315   149581     4734
    840 "2924" 2008 3 12109174  9718266  2390887
    124 "3230" 1997 3  3115197  2375291   726120
    124 "1543" 1993 1   383709   357086    26516
    840 "2101" 2005 1 16820008 15440660  1379348
    840 "1554" 1998 1   622418   509920   112498
    840 "1543" 2006 1  3292700  2074831  1217869
    840 "2914" 2001 3   547842   519432    28410
    840 "1531" 1997 1   594930   299553   295377
    124 "2731" 1996 2        .        .        .
    124 "1721" 2003 1   782655   350920   431735
    124 "3520" 1996 3   430546   422180     7108
    840 "1532" 2002 1   331635   285797    45838
    124 "2511" 1993 2   856093   841282    14628
    124 "3130" 1997 3   594931   553164    40358
    840 "3520" 1997 3  1228222  1162915    65306
    124 "1712" 1990 1        .        .        .
    840 "1554" 2007 1  2218695  1707226   511470
    840 "2424" 1997 3  2382143  2099582   282557
    124 "1911" 1998 1   221612   158244    63232
    124 "3520" 1993 3   206628   202675     2222
    840 "1920" 2004 1 17403647  2245468 15158162
    124 "2422" 2000 3   928580   925829     2751
    124 "2720" 2000 2  3951518  3346359   605155
    124 "2694" 2002 2    70999    64712     6277
    840 "3430" 2003 3 38469529 28899691  9569688
    124 "1911" 2001 1   232738   163349    69389
    840 "3512" 2001 3  1113988  1069315    44673
    124 "3512" 1998 3   212025   209397     1917
    840 "2101" 1998 1 12921147 12236018   685127
    840 "1912" 2008 1  9039867  1568636  7470201
    124 "2731" 1990 2        .        .        .
    124 "1912" 1990 1   233886   131034   100071
    124 "1729" 1991 1   336512   328046     6369
    124 "3000" 1995 3  8724946  8098341   483210
    840 "2812" 1999 2   251200   208848    42353
    124 "2222" 2003 1    21343    21292       51
    840 "3530" 2008 3 35276166 31770272  3505894
    840 "2693" 1999 2  1230937   886310   344600
    840 "2430" 2000 3  1628752  1257979   370659
    840 "2211" 2005 1  2567069  1543521  1023458
    124 "2022" 1990 1    67646    64607     2469
    840 "3330" 2000 3  3459811  2519326   940445
    840 "3140" 2004 3  2517036  1270417  1246619
    124 "2022" 1996 1    89832    86566     3009
    840 "1722" 2002 1  1618624   503335  1115095
    840 "2893" 2002 2  8694382  5383893  3310476
    840 "1911" 2007 1   790448   350955   439493
    124 "2101" 1990 1  1175960  1117408    16259
    124 "2102" 1998 1   388888   370694    17688
    124 "2929" 1991 3  1627692  1605265    12557
    124 "2732" 2002 2        .        .        .
    840 "3530" 2004 3 24288321 21359394  2928729
    124 "2511" 1994 2   927907   910512    17223
    124 "2424" 2000 3  1613554  1585055    28497
    124 "3610" 1993 1  1610070  1352107   255703
    840 "2511" 2004 2  6759389  4911047  1848278
    840 "2230" 1999 1    11192    10677      515
    124 "1920" 1991 1   726501   502426   206903
    840 "2915" 1999 3  5108582  4413610   694953
    840 "3210" 2003 3 29464506 21614958  7849425
    124 "1729" 1993 1   464849   455030     7054
    840 "1542" 2007 1  1198604   248008   950596
    840 "1511" 1999 1  3786093  3257280   528780
    124 "3220" 2000 3  5110451  4411174   699200
    124 "3699" 2003 1  1071914   541370   530505
    840 "1911" 2008 1   668907   327393   341515
    124 "1920" 2001 1  1018635   298474   720155
    124 "1711" 1999 1  1447267  1119054   326656
    124 "2010" 1994 1   550034   534729    13759
    840 "2109" 2007 1  3109555  1939563  1169992
    840 "3420" 2006 3  2992554  1525400  1467154
    124 "2412" 1998 3   292598   291304     1266
    end.

  • #2
    Code:
    bysort country year: egen totalimp_country_ti3 = total(cond(tech_intensity == 3, ImportsWorld, .))
    By the way, the command you show for creating totalimp_country has extraneous material at the end: -(Total Imports from world to country j)-. I assume this is meant to be an explanatory comment. So it needs to be separated from the command itself by a preceding // or enclosed between /* and */.

    Also, somehow there is a stray period (.) after -end- in your -dataex-. Not sure how it got there, but it does cause a break if you try to run it.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      Code:
      bysort country year: egen totalimp_country_ti3 = total(cond(tech_intensity == 3, ImportsWorld, .))
      By the way, the command you show for creating totalimp_country has extraneous material at the end: -(Total Imports from world to country j)-. I assume this is meant to be an explanatory comment. So it needs to be separated from the command itself by a preceding // or enclosed between /* and */.

      Also, somehow there is a stray period (.) after -end- in your -dataex-. Not sure how it got there, but it does cause a break if you try to run it.
      Thank you very much, not sure how it got there but will check right now. I will run your syntax but use ImportsIndustrialized instead.

      Comment

      Working...
      X