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, or any other method, 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 for the output to show the variable note instead of the variable label, bypassing the truncation. The below code produces a table as pictured.
I'm using Stata 18 and using the dtable, label, notes and putdocx commands. It would be helpful to get this working for all sorts of exports with other commands, but I'm not sure if that is a different issue entirely. Full transparency, this is a repost.
I'm using Stata 18 and using the dtable, label, notes and putdocx commands. It would be helpful to get this working for all sorts of exports with other commands, but I'm not sure if that is a different issue entirely. Full transparency, this is a repost.
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%) ----------------------------------------------------------------------------------------------------------------------------------
Comment