Announcement

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

  • Export Value Labels to Excel/CSV

    How do i export value labels for each variables that i have to excel or csv

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(screener_sfemale_sperc_s26 demo_q22 demo_q24 pdyna_q57_1)
    . 5 1 1
    1 5 1 1
    . 5 1 2
    1 6 1 2
    . 5 1 2
    1 5 1 2
    2 . . .
    1 5 1 1
    1 5 1 1
    2 . . .
    end
    label values screener_sfemale_sperc_s26 screener_hiv_status
    label def screener_hiv_status 1 "HIV negative", modify
    label def screener_hiv_status 2 "HIV positive", modify
    label values demo_q22 religion
    label def religion 5 "Christianity (Other)", modify
    label def religion 6 "Islam", modify
    label values demo_q24 ethnicity
    label def ethnicity 1 "Black/ African", modify
    label values pdyna_q57_1 sexual_act
    label def sexual_act 1 "Voluntary", modify
    label def sexual_act 2 "Forced", modify
    ------------------ copy up to and including the previous line ------------------


  • #2
    See label save for creating a do-file with all labels, and also label list for listing them all (which you can combine with logging into a file for preserving the output).

    Comment


    • #3
      Thank you for that, the only shortfall is that the label save is not indicating by variables.
      For example:
      gender gen_vals 1 "Male" 2 "Female"

      Comment


      • #4
        the purpose of label save is to save the value labels definitions only.
        it will save the value labels even if they are not used in any variables!
        describe will save indicate which value label is used by which variable.

        Comment


        • #5
          If you decode each variable with value labels, you can then export the numeric and string versions side by side. There is some repetition in doing that, but the result is portable across many different programs.

          Code:
          ds, has(vallabel)
          gives you a list of variables with value labels attached.

          Comment


          • #6
            Perhaps you want uselabel, then export the created file to Excel?

            Best
            Daniel

            Comment


            • #7
              Thank you all , finally used which gave me something close to what i was looking for :

              Code:
               ds, has(vallabel)
              fre using myvalues.xls, replace combine

              Code:
              uselabel,var 
              return list
              uselabel,var is very organized interms of creating a dataframe summary for the value labels. But it doesn't include the variable names. Of which the variables associated to specific value label are stored in the stored reuslts of the command

              Comment

              Working...
              X