Hi,
I am trying to export all information of tabstat results to a new data frame.
Here's the code that worked.
* Example 1
Code:
clear
clear frames
sysuse auto
cap frame drop tabstats1
frames create tabstats1 str15(variable) mean sd min max
frames dir
tabstat price, stat(mean sd min max) save
matrix A = r(StatTotal)
frame post tabstats1 ("price") (A[1,1]) (A[2,1]) (A[3,1]) (A[4,1])
frame change tabstats1
In the following example, I want to use the tabstat with by option
* Example 2
Code:
clear
clear frames
sysuse auto
cap frame drop tabstats1
frames create tabstats1 str15(variable foreign) mean sd min max
frames dir
tabstat price, stat(mean sd min max) by(foreign) save
frame post tabstats1 ("price") ("domestic") (r(Stat1)[1,1]) (r(Stat1)[2,1]) (r(Stat1)[3,1]) (r(Stat1)[4,1])
frame post tabstats1 ("price") ("foreign") (r(Stat2)[1,1]) (r(Stat2)[2,1]) (r(Stat2)[3,1]) (r(Stat2)[4,1])
*frame post tabstats1 ("price") ("Total") (r(StatTotal)[1,1]) (r(StatTotal)[2,1]) (r(StatTotal)[3,1]) (r(StatTotal)[4,1])
frame change tabstats1
Code:
invalid syntax
r(198);
Thank you.

Comment