Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Display of missing by groups


From   Fred Wolfe <[email protected]>
To   [email protected], [email protected]
Subject   Re: st: Display of missing by groups
Date   Wed, 08 Feb 2006 07:55:37 -0600

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index