Announcement

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

  • Problem in Appending

    Hi

    I am going to append these two data sets, (master and using) variable Pais changes in data from i.g PT to SC for the year 2011, I mean in the using dataset, after appending and says: (label Países already defined).


    master:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double NPC_FIC long pais int year
    501615311 54 2010
    501006164 54 2010
    501619415 54 2010
    501025391 54 2010
    501623944 54 2010
    501048411 54 2010
    501050636 54 2010
    501051073 54 2010
    501054952 54 2010
    501626681 54 2010
    501627547 54 2010
    501628596 54 2010
    501079541 54 2010
    501633517 54 2010
    502481710 54 2010
    501147120 54 2010
    501652445 54 2010
    501657631 54 2010
    501991013 54 2010
    501666996 54 2010
    501993085 54 2010
    501680332 54 2010
    501681134 54 2010
    501681513 54 2010
    501682081 54 2010
    501995833 54 2010
    501996504 20 2010
    502483168 54 2010
    502286891 54 2010
    502287049 54 2010
    501689522 54 2010
    501689901 54 2010
    501448443 54 2010
    501691477 54 2010
    501692939 54 2010
    501693884 54 2010
    501694095 54 2010
    502248252 54 2010
    502011638 54 2010
    502011701 54 2010
    502248322 54 2010
    502294502 54 2010
    502011776 54 2010
    501694951 54 2010
    501018069 54 2010
    501624767 54 2010
    501051153 54 2010
    501108179 54 2010
    501648233 54 2010
    501658853 54 2010
    501683150 54 2010
    501997181 20 2010
    502286556 54 2010
    501690929 54 2010
    502011694 54 2010
    502509263 54 2010
    502011777 54 2010
    501624881 54 2010
    501642316 54 2010
    501675865 54 2010
    502489632 54 2010
    502010220 54 2010
    502509224 54 2010
    502011681 54 2010
    500982301 54 2010
    500989890 54 2010
    501618617 54 2010
    501034453 54 2010
    501624944 54 2010
    501047112 54 2010
    501073563 54 2010
    501075080 54 2010
    501079866 54 2010
    501091378 54 2010
    501099919 54 2010
    501980368 54 2010
    501111012 54 2010
    501111764 54 2010
    501140048 54 2010
    501650968 54 2010
    501652432 54 2010
    501162917 54 2010
    501656217 54 2010
    501191885 54 2010
    501666995 54 2010
    501667755 54 2010
    501673005 54 2010
    501674617 54 2010
    501993329 54 2010
    501678805 54 2010
    501680538 54 2010
    501681167 54 2010
    501994315 54 2010
    501681539 54 2010
    501994445 54 2010
    501682741 54 2010
    501995349 54 2010
    501995361 54 2010
    501995603 54 2010
    501995888 54 2010
    end
    label values pais Países
    label def Países 20 "ES", modify
    label def Países 54 "PT", modify

    using:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double NPC_FIC long pais int year
    500982050 56 2011
    501006164 56 2011
    501619415 56 2011
    501025391 56 2011
    501623944 56 2011
    501054211 56 2011
    501054952 56 2011
    501626681 56 2011
    501627547 56 2011
    501628596 56 2011
    501073535 56 2011
    501079541 56 2011
    501632538 56 2011
    501633517 56 2011
    502481710 56 2011
    501639836 56 2011
    501147120 56 2011
    501652445 56 2011
    501657631 56 2011
    501184201 56 2011
    501991013 56 2011
    501219587 56 2011
    501993085 56 2011
    501680332 56 2011
    501681134 56 2011
    501681513 56 2011
    501682081 56 2011
    501995871 56 2011
    502483168 56 2011
    502287049 56 2011
    502489743 56 2011
    502501883 56 2011
    501689901 56 2011
    501690041 56 2011
    501448443 56 2011
    501448452 56 2011
    501691477 56 2011
    501692939 56 2011
    501693884 56 2011
    501694095 56 2011
    502011701 56 2011
    502248322 56 2011
    502294502 56 2011
    501018069 56 2011
    501624767 56 2011
    501051153 56 2011
    501108179 56 2011
    501997181 21 2011
    501690929 56 2011
    502011694 56 2011
    502509263 56 2011
    502011777 56 2011
    501642316 56 2011
    501675865 56 2011
    502489632 56 2011
    502011681 56 2011
    500982301 56 2011
    500989890 56 2011
    501618617 56 2011
    501016340 56 2011
    501034453 56 2011
    501624944 56 2011
    501047112 56 2011
    501073563 56 2011
    501079866 56 2011
    501091378 56 2011
    501635483 56 2011
    501111012 56 2011
    501111487 56 2011
    501111764 56 2011
    501643299 56 2011
    501652077 56 2011
    501652432 56 2011
    501162917 56 2011
    501666995 56 2011
    501667755 56 2011
    501673005 56 2011
    501674617 56 2011
    501254729 56 2011
    501993329 56 2011
    501678805 56 2011
    501680538 56 2011
    501681167 56 2011
    501994315 56 2011
    501681539 56 2011
    501994445 56 2011
    501682106 56 2011
    501682741 56 2011
    501995603 56 2011
    501995888 56 2011
    501996487 56 2011
    502482734 56 2011
    502482786 56 2011
    502482798 56 2011
    502482929 56 2011
    501998404 56 2011
    501998758 56 2011
    502286235 56 2011
    502483822 56 2011
    502286459 56 2011
    end
    label values pais Países
    label def Países 21 "ES", modify
    label def Países 56 "PT", modify
    [CODE]
    The result after appending:
    append using "C:\Users\35193\Desktop\using.dta"
    (label Países already defined)
    Code:
    NPC_FIC    pais    year
    501841003    PT    2010
    501841015    PT    2010
    501841016    PT    2010
    501841020    PT    2010
    500982050    SC    2011
    501006164    SC    2011
    501619415    SC    2011
    501025391    SC    2011
    501623944    SC    2011
    501054211    SC    2011
    501054952    SC    2011
    501626681    SC    2011
    501627547    SC    2011
    501628596    SC    2011
    501073535    SC    2011
    501079541    SC    2011
    501632538    SC    2011
    501633517    SC    2011
    502481710    SC    2011
    501639836    SC    2011
    501147120    SC    2011
    501652445    SC    2011
    501657631    SC    2011
    501184201    SC    2011
    501991013    SC    2011
    501219587    SC    2011
    501993085    SC    2011
    501680332    SC    2011
    501681134    SC    2011
    501681513    SC    2011
    501682081    SC    2011
    501995871    SC    2011
    502483168    SC    2011
    502287049    SC    2011
    502489743    SC    2011
    502501883    SC    2011
    501689901    SC    2011
    501690041    SC    2011
    501448443    SC    2011
    501448452    SC    2011
    501691477    SC    2011
    501692939    SC    2011
    501693884    SC    2011
    Any ideas appreciated.
    Cheers,
    Paris

  • #2
    I think there's an option (I think) in the help that specifies to not overwrite value labels

    Comment


    • #3
      Code:
       use "C:\Users\35193\Desktop\master.dta", clear
      
      . append using "C:\Users\35193\Desktop\using.dta",nolabel
      
      NPC_FIC    pais    year    
      501841003    PT    2010    
      501841015    PT    2010    
      501841016    PT    2010    
      501841020    PT    2010    
      500982050    SC    2011    
      501006164    SC    2011    
      501619415    SC    2011    
      501025391    SC    2011    
      501623944    SC    2011    
      501054211    SC    2011    
      501054952    SC    2011    
      501626681    SC    2011    
      501627547    SC    2011    
      501628596    SC    2011    
      501073535    SC    2011    
      501079541    SC    2011    
      501632538    SC    2011    
      501633517    SC    2011    
      502481710    SC    2011    
      501639836    SC    2011    
      501147120    SC    2011    
      501652445    SC    2011    
      501657631    SC    2011    
      501184201    SC    2011    
      501991013    SC    2011    
      501219587    SC    2011    
      501993085    SC    2011    
      501680332    SC    2011    
      501681134    SC    2011    
      501681513    SC    2011    
      501682081    SC    2011    
      501995871    SC    2011    
      502483168    SC    2011    
      502287049    SC    2011    
      502489743    SC    2011    
      502501883    SC    2011    
      501689901    SC    2011    
      501690041    SC    2011    
      501448443    SC    2011    
      501448452    SC    2011    
      501691477    SC    2011    
      501692939    SC    2011    
      501693884    SC    2011    
      501694095    SC    2011    
      502011701    SC    2011    
      502248322    SC    2011    
      502294502    SC    2011    
      501018069    SC    2011    
      501624767    SC    2011    
      501051153    SC    2011    
      501108179    SC    2011    
      501997181    FI    2011    
      501690929    SC    2011    
      502011694    SC    2011    
      502509263    SC    2011    
      502011777    SC    2011    
      501642316    SC    2011    
      501675865    SC    2011    
      502489632    SC    2011    
      502011681    SC    2011    
      500982301    SC    2011
      It does not solve the problem.

      Comment


      • #4
        The Paises value labels in your first dataset do not agree with the Paises value labels in your second dataset. In your first dataset "PT" corresponds to 54; in your second datset "PT" corresponds to 56.

        It is usually a mistake to use the encode command separately on the same variable in different datasets that eventually are going to be appended or merged.

        Before appending, separately in each of your two datasets run
        Code:
        decode pais, generate(pais_str)
        drop pais
        to re-create the original string variables containing two-letter codes.

        Then, after you append the two datasets,
        Code:
        encode pais_str, generate(pais)

        Comment


        • #5
          Thank you so much Prof.

          Comment

          Working...
          X