I am trying to create a correlation matrix in Stata that a) includes the number of observations for each row and b) can be exported to a .docx or .rtf file. I am currently using estout, specifically the estpost corr option. My problem is that estpost corr reports the e(count) number in the last column, but using esttab with the unstack option makes the e(count) disappear. Since estpost corr returns e(count) as vector, there should be a way to add these, but I am not sure how. I want the correlations to be formatted like unstack does. I just want one new column with the number of observations after the variable names / labels. I am using Stata 18 on Windows 10.
The title should read "for each variable using esttab" instead of "for each variable pair using esttab".
Here is how an illustration where I want to insert the number of observations:
Crossposted on Stackoverflow.
The title should read "for each variable using esttab" instead of "for each variable pair using esttab".
Code:
input id trial1 trial2 trial3 1 1.5 1.4 1.6 2 1.5 . 1.9 3 . 2.0 1.6 4 . . 2.2 5 1.9 2.1 2 6 1.8 2.0 1.9 7 . . . end estpost corr trial1 trial2 trial3, matrix esttab using correlations.rtf, replace unstack
Code:
input nobs trial1 trial2 trial3 4 1 . . 3 0.994 1 . 6 0.700 0.644 1 end
Comment