I wish to export a matrix (or list) of variable labels from Stata to Tex. I though I'd do this by filling matrix with the labels, and then exporting via frmttable. However, I just realized that stata matrices cannot hold strings. Under any circumstances?
Below is a reproducible example of what I'd *like* to do, except that the last mata st_matrix command doesn't run. In fact, normally this loop wouldn't involve mata at all, Sstats would be created as a stata matrix directly.
Is there some way to export a series of 20-25 variable labels automatically, in a 1 column table, that doesn't involve matrices? Or can I somehow force a string-based matrix from mata? Thanks!
Below is a reproducible example of what I'd *like* to do, except that the last mata st_matrix command doesn't run. In fact, normally this loop wouldn't involve mata at all, Sstats would be created as a stata matrix directly.
Is there some way to export a series of 20-25 variable labels automatically, in a 1 column table, that doesn't involve matrices? Or can I somehow force a string-based matrix from mata? Thanks!
Code:
sysuse auto.dta, clear gl mylist mpg rep78 headroom trunk weight length turn displacement gear_ratio clear matrix local rows = 0 foreach var of varlist $mylist { local rows = `rows'+1 } local cols 1 mata Sstats = J(`rows',`cols',"") tokenize "$mylist" forval i = 1/`rows' { local x : variable label ``i'' mata Sstats[`i',1]= "`x'" di "`x'" } mata Sstats mata st_matrix("Sstats",Sstats)
Comment