Announcement

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

  • How to export variable name, variable labels and value labels to an excel?

    Hi all,

    I'm trying to create a data dictionary by exporting the following details: variable name, variable label, value labels to an excel.

    I followed a previous discussion here and did the following:

    Code:
    use "$data\data.dta"
    
    gen i=_n
    keep if i==1
    
    
        describe, replace clear
        list
        export excel using "$raw_data\data dictionary.xlsx", replace first(var)
    Only problem is, with this code I get name of the value label for a variable and not the labeled values.

    For instance, using label list I got

    Code:
    label list
    binary:
               0 No
               1 Yes
    roundlabel:
               1 1992-93
               2 1998-2000
               3 2005-06
               4 2015-2016
               5 2019-21
    urblabel:
               0 rural
               1 urban
    maritallabel:
               0 widowed/never married/divorced/not living together
               1 married and living together
    child_sexlabel:
               0 female
               1 male
    I want this information on value labels to appear next to the variables. So what I'm looking for is something like the following:
    variable value label
    region 0 rural
    1 urban
    So, somewhat like that appears with codebook

    I tried the method outlined in #5 of the link but got the error
    Code:
    not possible with numeric variable
    Would appreciate any help
    Thanks!



Working...
X