Announcement

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

  • Export variable notes instead of variable labels

    I have some variable labels that are longer than 80 characters that I'd like to export to a table. I was wondering if there is a way to use notes as a workaround for the variable label character limit. In the below example I've attached both a label and note to the variable of interest, but I'd like to attach the note as the label when exporting this table. Due to the variable label limit it is obviously being truncated.

    Code:
    clear
    set seed 82
    set obs 1000
    g female = runiformint(0,1)
    label define female 0 "Male" 1 "Female"
    label values female female
    g cont = female + runiformint(1,7) + runiform() if runiform() > .05
    g cat = 1
    replace cat = 2 if cont > 2
    replace cat = 3 if cont > 5
    la var cont "Continuous variable"
    la var cat "This is a question with multiple answer choices, where the question is longer than 80 characters"
    notes cat : "This is a question with multiple answer choices, where the question is longer than 80 characters"
    
    dtable cont i.cat, by(female, tests)
    putdocx begin
    putdocx collect
    putdocx save mytable, replace
    
    
    ----------------------------------------------------------------------------------------------------------------------------------
                                                                                                           female                     
                                                                                          Male         Female         Total      Test
    ----------------------------------------------------------------------------------------------------------------------------------
    N                                                                                  501 (50.1%)   499 (49.9%) 1,000 (100.0%)       
    Continuous variable                                                              4.513 (2.067) 5.453 (2.024)  4.977 (2.098) <0.001
    This is a question with multiple answer choices, where the question is longer th                                                  
      1                                                                                 65 (13.0%)      0 (0.0%)      65 (6.5%) <0.001
      2                                                                                208 (41.5%)   206 (41.3%)    414 (41.4%)       
      3                                                                                228 (45.5%)   293 (58.7%)    521 (52.1%)       
    ----------------------------------------------------------------------------------------------------------------------------------
Working...
X