Thanks, Crystal.
Below is my code:
===
*Re-label variables to be clearer in table
label define bmi2obesevsrestlab 0 "Not obese" 1 "Obese"
label values bmi2obesevsrest bmi2obesevsrestlab
rename variable bmi2obesevsrest "BMI Group"
label variable coll_egg_age "Age (yrs)"
label variable bmi2 "Body mass index"
label variable mii_total "Mature eggs collected"
*Table 1 commands to export to doc
tabstat coll_egg_age bmi2 mii_total, by(bmi2obesevsrest) stat(mean sd) col(stat) long nototal save
return list
matrix obesestats = r(Stat2)'
matlist obesestats
matrix nonobesestats = r(Stat1)'
matlist nonobesestats
putdocx clear
putdocx begin
putdocx table ObeseTable1 = matrix(obesestats), rownames colnames layout(autofitcontents) title("Obese Group")
putdocx table NonObeseTable1 = matrix(nonobesestats), rownames colnames layout(autofitcontents) title("Non-obese Group")
putdocx save "Final Project.docx", replace
===
I tried
1) adding "varlabel" as an option
(putdocx table ObeseTable1 = matrix(obesestats), rownames colnames layout(autofitcontents) title("Obese Group") varlabel)
But I get the error: "option varlabel not allowed"
2) changing from labeling to renaming the variables
(rename variable bmi2obesevsrest BMI_Group)
But I get the error: "syntax error
Syntax is
rename oldname newname [, renumber[(#)] addnumber[(#)] sort ...]
rename (oldnames) (newnames) [, renumber[(#)] addnumber[(#)] sort ...]
rename oldnames , {upper|lower|proper}"
I'm totally fine editing the variable names directly in the word document, but wanted to make sure I wasn't missing something I should've learned from class.
Appreciate the help!