Guilio said
>gen group2 = .
>gen proportion2 = .
>
>qui tab trunk
>local N = r(r)
>
>tabstat trunk foreign , by(trunk) stat(mean) save
>
>forv i = 1(1)`N' {
>mat M = r(Stat`i')
>scalar name = M[1,1]
>scalar prop = M[1,2]
>qui replace group2 = scalar(name) in `i'
>qui replace proportion2 = scalar(prop) in `i'
>}
>
>l group* proportion* if group in 1/18
Many thanks to Orsini Coviello and Baum for their rapid response and
many
solutions.
Orsini's solution recorded above was the one I was really interested
in: It
shows how to read in useful variables the results saved in r( ) by tab
program, a useful piece of information that is missing in the help of
the
return command.
Thank you all again
Giulio Rizzoli
I find the way in which tabstat stores its results to be excessively
cumbersome.
Another way is to avoid tabstat entirely and do it in two commands: