I don't see why this would be a problem, as -by- already has the options
-sort- and -rc0-.
Still, I would go with -tabstat, by()- anyway, as the output is
formatted much more attractively.
David
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Fred Wolfe
Sent: 08 February 2006 13:56
To: [email protected]; [email protected]
Subject: Re: st: Display of missing by groups
I guess it must be difficult for Stata to put in an option to -by-, such
as
by x, nomiss: command
But it would save repeated lines of code when one didn't want to display
data for the missing group.
Thanks,
Fred
At 07:23 AM 2/8/2006, [email protected] wrote:
>Rather than using -bys ranada: sum haq- you could use -tabstat haq, by
>(ranada)-. Or -levelsof- and -foreach- to cycle through the groups.
>
>tabstat mpg weight if mpg >10, by(rep) /// stat(N mean sd min max )
>c(s) nototal
>
>
>levelsof rep, local(levels)
>foreach l of local levels {
> sum mpg weight if mpg > 10 & rep == `l'
>}
>
>
>Scott
>
>
>----- Original Message -----
>From: Fred Wolfe <[email protected]>
>Date: Wednesday, February 8, 2006 7:02 am
>Subject: st: Display of missing by groups
>
> > Statalisters,
> >
> > I keep thinking there must be an easy solution to this problem, but
> > I can't find it. This code always produces a . (missing) bygroup.
> >
> > . bys ranada: su haq* if full ==1 & newenc ==3 & ranada !=.
> >
> > -------------------------------------------------------------------
> > ---------------------------------------------------------
> > -> ranada = 0
> >
> > Variable | Obs Mean Std. Dev. Min
> > Max
> > -------------+-----------------------------------------------------
> > ---
> > haq_disabi~y | 917 1.106325 .6579799 0
> > 3
> > haq2 | 915 1.07224 .6258604 0
> > 2.9
> >
> > -------------------------------------------------------------------
> > ---------------------------------------------------------
> > -> ranada = 1
> >
> > Variable | Obs Mean Std. Dev. Min
> > Max
> > -------------+-----------------------------------------------------
> > ---
> > haq_disabi~y | 969 1.103844 .6835943 0
> > 3
> > haq2 | 967 1.065047 .6345786 0
> > 2.8
> >
> > -------------------------------------------------------------------
> > ---------------------------------------------------------
> > -> ranada = .
> >
> > Variable | Obs Mean Std. Dev. Min
> > Max
> > -------------+-----------------------------------------------------
> > ---
> > haq_disabi~y | 0
> > haq2 | 0
> >
> >
> > However, I don't want to display the missing by group. I know that I
> > can -preserve-, -drop if ranada == .-, run the code, and then
> > -restore-.
> >
> > But is there an easier way?
> >
> > Thanks,
> >
> > Fred
> >
>
>*
>* 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/
Fred Wolfe
National Data Bank for Rheumatic Diseases Wichita, Kansas
Tel (316) 263-2125 Fax (316) 263-0761
[email protected]
*
* 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/
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
*
* 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/