I know we can use esttab to make tables from matrices. And that's all well and good. But, what I want, is to use Stata's table command to accomplish this.
All I want is for the rows to be what they are, and the numbers in those rows to be the single column of interest. At present, the preview section of the table editor says "Your layout specification does not identify any items."
Is there a straightforward way to simply collect a matrix into a table and continue editing from there? At present, the row names are there, but the column of totals isn't there.
Code:
* Example generated by -dataex-. For more info, type help dataex collect clear clear input str39 pops double Totals "Alcohol users" 5 "Auto insured" 2 "Cannabis users" 17 "Children in need of protective services" 3 "College students" 21 "Crash-involved individuals" 10 "Crime victims" 1 "Criminal justice involved" 63 "Decedents" 36 "Disability claimants" 2 "Drug treatment clients" 15 "Elementary school students" 1 "Females" 1 "Festival/nightlife participants" 2 "General population" 87 "High school students" 41 "Hospital patients" 24 "Internet/social media users" 19 "Law enforcement" 2 "Medical professionals" 2 "Medically insured" 14 "Middle school students" 21 "Newborns" 5 "Other groups" 19 "Outpatients" 7 "Parents" 3 "People with health conditions" 15 "Poison center patients" 12 "Pregnant/postpartum women" 9 "Prescription drug users" 11 "Property buyers/renters" 9 "Proprietary survey panelist" 10 "Tobacco users" 6 "Tourists/travelers" 3 "Urban population" 13 "Vehicle drivers" 24 "Workforce participants" 11 end tempvar id egen `id' = group(pops) cls g sort = 1 if inlist(`id',9,13,15,23,24,26,32,35,37) //gen pop replace sort = 2 if inlist(`id',1,3,30,33) // drug users replace sort = 3 if inlist(`id',5,12,16,22) // education replace sort = 4 if inlist(`id',2,14,18,31,32,34) // consumers replace sort = 5 if inlist(`id',7,8,19) // criminal justice replace sort = 6 if inlist(`id',17,20,21,25,28,29) // medical replace sort = 7 if inlist(`id',4,10,11,27) // at-risk replace sort = 8 if inlist(`id',6,36) // cars as !mi(sort) gsort sort -Totals mkmat Totals, rownames(pops) mat(Populations) cls loc a: display "`: colname Populations'" loc b: display "`: rowname Populations'" mat l Populations collect style autolevels `a' Totals collect layout (`b') (colname)
Is there a straightforward way to simply collect a matrix into a table and continue editing from there? At present, the row names are there, but the column of totals isn't there.

Comment