Announcement

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

  • Value labels for variable including multiple International Standard Industrial Classification (ISIC) codes

    Using Stata 13, I have wrote the following code to attach value labels to each isic code:

    Code:
    label define isic10 10 "Mining of coal and lignite";
    label value isic isic10;
    label define isic12 12 "Mining of uranium and thorium ores";
    label value isic isic12;
    label define isic13 13 "Mining of metal ores";
    label value isic isic13;
    label define isic14 14 "Other mining and quarrying";
    label value isic isic14;
    
    *-Manufacturing-*;
    label define isic15 15 "Manufacture of food products and beverages";
    label value isic isic15;
    label define isic16 16 "Manufacture of tobacco products";
    label value isic isic16;
    label define isic17 17 "Manufacture of textiles";
    label value isic isic17;
    label define isic18 18 "Manufacture of wearing apparel";
    label value isic isic18;
    label define isic19 19 "Tanning and dressing of leather; manufacture of luggage, handbags, saddlery, harness and footwear";
    label value isic isic19;
    label define isic20 20 "Manufacture of wood and of products of wood and cork";
    label value isic isic20;
    label define isic21 21 "Manufacture of paper and paper products";
    label value isic isic21;
    label define isic22 22 "Publishing, printing and reproduction of recorded media";
    label value isic isic22;
    label define isic23 23 "Manufacture of coke, refined petroleum products and nuclear fuel";
    label value isic isic23;
    label define isic24 24 "Manufacture of chemicals and chemical products";
    label value isic isic24;
    label define isic25 25 "Manufacture of rubber and plastics products";
    label value isic isic25;
    label define isic26 26 "Manufacture of other non-metallic mineral products";
    label value isic isic26;
    label define isic27 27 "Manufacture of basic metals";
    label value isic isic27;
    label define isic28 28 "Manufacture of fabricated metal products";
    label value isic isic28;
    label define isic29 29 "Manufacture of machinery and equipment";
    label value isic isic29;
    label define isic30 30 "Manufacture of office, accounting and computing machinery";
    label value isic isic30;
    label define isic31 31 "Manufacture of electrical machinery and apparatus";
    label value isic isic31;
    label define isic32 32 "Manufacture of radio, television and communication equipment and apparatus";
    label value isic isic32;
    label define isic33 33 "Manufacture of medical, precision and optical instruments, watches and clocks";
    label value isic isic33;
    label define isic34 34 "Manufacture of motor vehicles, trailers and semi-trailers";
    label value isic isic34;
    label define isic35 35 "Manufacture of other transport equipment";
    label value isic isic35;
    label define isic36 36 "Manufacture of furniture";
    label value isic isic36;
    label define isic37 37 "Recycling";
    label value isic isic37;
    
    *-Electricity, gas and water supply-*;
    label define isic40 40 "Electricity, gas, steam and hot water supply";
    label value isic isic40;
    
    *-Construction-*;
    label define isic45 45 "Construction";
    label value isic isic45;
    
    *-Wholesale and retail trade repair of motor vehicles, motorcycles and personal and household goods-*;
    label define isic50 50 "Sale, maintenance and repair of motor vehicles and motorcycles; retail sale of automotive fuel";
    label value isic isic50;
    label define isic51 51 "Wholesale trade and commission trade; except of motor vehicles and motorcycles";
    label value isic isic51;
    label define isic52 52 "Retail trade, except of motor vehicles and motorcycles; repair of personal and household goods";
    label value isic isic52;
    
    *-Hotels and restaurants-*;
    label define isic55 55 "Hotels and restaurants";
    label value isic isic55;
    
    *-Transport, storage and communications-*;
    label define isic60 60 "Land transport; transport via pipelines";
    label value isic isic60;
    label define isic61 61 "Water transport";
    label value isic isic61;
    label define isic62 62 "Air transport";
    label value isic isic62;
    label define isic63 63 "Supporting and auxiliary transport activities; activities of travel agencies";
    label value isic isic63;
    label define isic64 64 "Post and telecommunications";
    label value isic isic64;
    
    *-Financial intermediation-*;
    label define isic65 65 "Financial intermediation, except insurance and pension funding";
    label value isic isic65;
    label define isic67 67 "Activities auxiliary to financial intermediation";
    label value isic isic67;
    
    *-Real estate, renting and business activities-*;
    label define isic70 70 "Real estate activities";
    label value isic isic70;
    label define isic71 71 "Renting of machinery and equipment without operator and of personal and household goods";
    label value isic isic71;
    label define isic72 72 "Computer and related activities";
    label value isic isic72;
    label define isic74 74 "Other business activities";
    label value isic isic74;
    However, it seems that this will only add the label value to the last isic code, given the syntax of the command, as shown using -tab-:

    Code:
           ISIC code 2 digits |      Freq.     Percent        Cum.
    --------------------------+-----------------------------------
                           10 |          3        0.00        0.00
                           12 |          2        0.00        0.01
                           13 |          8        0.01        0.01
                           14 |          7        0.01        0.02
                           15 |     11,826       12.47       12.49
                           16 |        219        0.23       12.72
                           17 |      4,402        4.64       17.36
                           18 |      6,482        6.83       24.20
                           19 |      1,295        1.37       25.56
                           20 |      1,872        1.97       27.54
                           21 |        752        0.79       28.33
                           22 |      2,016        2.13       30.46
                           23 |        128        0.13       30.59
                           24 |      4,786        5.05       35.64
                           25 |      3,251        3.43       39.06
                           26 |      3,856        4.07       43.13
                           27 |      1,607        1.69       44.82
                           28 |      4,773        5.03       49.86
                           29 |      3,294        3.47       53.33
                           30 |         37        0.04       53.37
                           31 |      1,644        1.73       55.10
                           32 |        322        0.34       55.44
                           33 |        336        0.35       55.80
                           34 |      1,096        1.16       56.95
                           35 |        262        0.28       57.23
                           36 |      2,958        3.12       60.35
                           37 |        119        0.13       60.47
                           40 |          5        0.01       60.48
                           41 |          1        0.00       60.48
                           45 |      4,518        4.76       65.24
                           50 |      2,893        3.05       68.29
                           51 |      6,533        6.89       75.18
                           52 |     13,650       14.39       89.58
                           53 |          2        0.00       89.58
                           55 |      4,527        4.77       94.35
                           57 |          1        0.00       94.35
                           60 |      1,404        1.48       95.83
                           61 |        159        0.17       96.00
                           62 |         92        0.10       96.10
                           63 |      1,284        1.35       97.45
                           64 |        540        0.57       98.02
                           65 |          4        0.00       98.02
                           66 |          2        0.00       98.03
                           67 |          1        0.00       98.03
                           70 |         55        0.06       98.09
                           71 |          7        0.01       98.09
                           72 |      1,677        1.77       99.86
                           73 |          3        0.00       99.86
    Other business activities |         47        0.05       99.91
    Is there a way around this problem or perhaps another Stata command that I can use to achieve this for all isic codes within the variable?
    Last edited by David Clark; 01 Sep 2015, 09:00. Reason: Adding tags.

  • #2
    You define a set of value labels and attach a set to a variable once. As you say, you can do that more than once but then you overwrite any previously defined values, at least the way you did it.

    Code:
    label def isic 10 "Mining of coal and lignite", modify
    label def isic 12 "Mining of uranium and thorium ores", modify
    label def isic 13 "Mining of metal ores", modify
    label def isic 14 "Other mining and quarrying", modify
    label def isic 15 "Manufacture of food products and beverages", modify
    label def isic 16 "Manufacture of tobacco products", modify
    label def isic 17 "Manufacture of textiles", modify
    label def isic 18 "Manufacture of wearing apparel", modify
    label def isic 19 "Tanning and dressing of leather, modify manufacture of luggage, handbags, saddlery, harness and footwear", modify
    label def isic 20 "Manufacture of wood and of products of wood and cork", modify
    label def isic 21 "Manufacture of paper and paper products", modify
    label def isic 22 "Publishing, printing and reproduction of recorded media", modify
    label def isic 23 "Manufacture of coke, refined petroleum products and nuclear fuel", modify
    label def isic 24 "Manufacture of chemicals and chemical products", modify
    label def isic 25 "Manufacture of rubber and plastics products", modify
    label def isic 26 "Manufacture of other non-metallic mineral products", modify
    label def isic 27 "Manufacture of basic metals", modify
    label def isic 28 "Manufacture of fabricated metal products", modify
    label def isic 29 "Manufacture of machinery and equipment", modify
    label def isic 30 "Manufacture of office, accounting and computing machinery", modify
    label def isic 31 "Manufacture of electrical machinery and apparatus", modify
    label def isic 32 "Manufacture of radio, television and communication equipment and apparatus", modify
    label def isic 33 "Manufacture of medical, precision and optical instruments, watches and clocks", modify
    label def isic 34 "Manufacture of motor vehicles, trailers and semi-trailers", modify
    label def isic 35 "Manufacture of other transport equipment", modify
    label def isic 36 "Manufacture of furniture", modify
    label def isic 37 "Recycling", modify
    label def isic 40 "Electricity, gas, steam and hot water supply", modify
    label def isic 45 "Construction", modify
    label def isic 50 "Sale, maintenance and repair of motor vehicles and motorcycles, modify retail sale of automotive fuel", modify
    label def isic 51 "Wholesale trade and commission trade, modify except of motor vehicles and motorcycles", modify
    label def isic 52 "Retail trade, except of motor vehicles and motorcycles, modify repair of personal and household goods", modify
    label def isic 55 "Hotels and restaurants", modify
    label def isic 60 "Land transport, modify transport via pipelines", modify
    label def isic 61 "Water transport", modify
    label def isic 62 "Air transport", modify
    label def isic 63 "Supporting and auxiliary transport activities, modify activities of travel agencies", modify
    label def isic 64 "Post and telecommunications", modify
    label def isic 65 "Financial intermediation, except insurance and pension funding", modify
    label def isic 67 "Activities auxiliary to financial intermediation", modify
    label def isic 70 "Real estate activities", modify
    label def isic 71 "Renting of machinery and equipment without operator and of personal and household goods", modify
    label def isic 72 "Computer and related activities", modify
    label def isic 74 "Other business activities", modify
    
    label val isic isic

    Comment


    • #3
      Starting from what you have, you can download labutil2 (SSC) to get one integrated set of value labels.

      Code:
      // get all isic* value labels in memory
      labunab mylabels : isic*
      
      // combine the labels
      labvalpool isic `mylabels'
      
      // drop the individual labels
      label drop `mylabels'
      For step 2 above also see labvalcombine (labutil, Cox, SSC).

      I am currently working on a package to accomplish such tasks a little bit more convenient.

      Best
      Daniel

      Comment


      • #4
        Originally posted by daniel klein View Post
        Starting from what you have, you can download labutil2 (SSC) to get one integrated set of value labels.

        Code:
        // get all isic* value labels in memory
        labunab mylabels : isic*
        
        // combine the labels
        labvalpool isic `mylabels'
        
        // drop the individual labels
        label drop `mylabels'
        For step 2 above also see labvalcombine (labutil, Cox, SSC).

        I am currently working on a package to accomplish such tasks a little bit more convenient.

        Best
        Daniel
        Daniel,

        Many thanks for making me aware of these commands; I look forward to the release of your self-written package for this.

        Comment

        Working...
        X