Announcement

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

  • Changing three-language value labels of a variable into one-language value labels

    I imported survey data into STATA from RedCap software. Three languages were used while administering the survey questions. As a result, the RedCap and consequently the STATA generated value labels for the variables in a combination of all three languages. These languages are separated by commas. I assume these value labels are in Unicode format to support local languages. Now I would like to keep these value labels in one language only. Preferably in English. How could it be done from the existing database and without reassigning new value labels to the variables?

    Thank you all for your help in advance.

  • #2
    Please show a minimal reproducible example.

    Comment


    • #3
      I wrote a quick package n_lab for doing something like that. See https://github.com/maartenteaches/n_lab for how to install it within Stata. After you have installed it, you can just open your dataset, and if the English labels are the second label, then type n_lab , n(2)
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Drawing on Maarten's example dataset, here is one way to define labels for all languages using elabel (GitHub, SSC):

        Code:
        // example data
        clear
        input female urban
        0 1
        0 2
        1 3
        1 3
        2 2
        end
        
        label define fem_lb 0 "male, man, mänlich" ///
                            1 "female, vrouw, weiblich" ///
                            2 "other, anders, divers"
        
        label define urb_lb 1 "rural, ruraal, ländlich" ///
                            2 "suburban, dorp, kleinstadt" ///
                            3 "city, stad, stadt"
        
        label value female fem_lb
        label value urban urb_lb
        
        list
        
        // define labels in all languages
        preserve
        
        uselabel , clear
        split label , parse(",")
        
        list // just to show the working data
        
        local i 0
        foreach language in en nl de {
            tempfile `language'
            elabel load using . , label(label`++i')
            elabel rename * *_`language'
            label save using ``language''
            label drop _all
        }
        
        restore
        
        foreach language in en nl de {
            do ``language''
        }
        
        // done
        label list

        Comment


        • #5
          Thanks, it was useful!!

          Comment

          Working...
          X