Use -levelsof- and -foreach-.
For example:
sysuse auto,clear
levelsof rep, local(levels)
foreach l of local levels {
qui reg mpg price if rep == `l'
est store A`l'
}
est table A*
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Alan Marshall
> Sent: Wednesday, August 16, 2006 10:58 AM
> To: [email protected]
> Subject: Re: st: -by varname- and -est store-
>
> Dear Bernhard,
>
> Coincidentally I was about to email the stata list with almost exactly
> the same
> question! I'm using the by command with nl (non linear regression) and I
> also
> want to store my parameter estimates but can only retieve the estimates
> assocaited with the last by variable.
>
> I'd really appreciate it if you could forward any advice you recieve on to
> me.
>
> Thanks
>
> Alan
>
> Quoting Bernhard Ganglmair <[email protected]>:
>
> > Hi,
> >
> > I am struggling with -by- and the -estimates- command. Hopefully
> > somebody can give me a hint.
> >
> > I estimate a bivariate probit model for each value of the variable
> > varname using clustered data, i.e. for various sub-populations
> > defined by varname. The first approach that came into my mind was
> > just running the biprobit with if varname==some value. The Stata
> > manual on survey, however, tells me that I would incorrect variance
> > estimates if I used -if-. It is suggested to use the by() or subpop()
> > option. Since byprobit doesn't allow for by() or subpop() [version 8;
> > no svybiprobit], I am running the following:
> >
> > by varname, sort: biprobit y1 y2 varlist, cluster(ea)
> >
> > For each value of varname I'd like to store the estimation results,
> > -est store- however gives me only the results of the last value in
> > varname.
> >
> > How do I address results generated using -by-?
> >
> > Best, Bernhard
*
* 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/