But this is like going from Padova to Venezia via Milano
and Firenze. You'd see a lot on the way, and
you could meet some friends, but it is still a very
indirect route.
As others have pointed out, -tabstat- is a pretty
awkward device for getting the means into
a variable, which seems your main concern here.
egen mean = mean(foreign), by(trunk)
is much more direct.
Nick
[email protected]
Giulio Rizzoli
> >In aggiunta alla email precedente, volendo usare tabstat, un
> modo pu�
> >essere questo
> >
> >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.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/