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

Re: st: Getting the exact number of obs. a graph is based on

From   "Austin Nichols" <>
Subject   Re: st: Getting the exact number of obs. a graph is based on
Date   Mon, 1 Oct 2007 17:31:07 -0400

Jesper Kjr Hansen <>:

I don't think there is one procedure that would work for all graphs.
You might think a -serset- call would give that info, but many graphs
do not encode information on all observations used (e.g. -gr box-
throws out a lot of info).  A -tw- graph might use information on 100
observations but use different observations for different plots on the
same graph, so it's not clear what number(s) should be reported in
every instance.  E.g. in

sysuse auto, clear
replace pr=. if rep78==1
replace wei=. if rep78==2
scatter pr wei mpg

what number of obs would you like returned?  In any case, I think your
general approach will work for most cases you might care about, but I
would remind you to include weights as a qualifier (perhaps accounting
for zero, negative, and missing weights as applicable) too.

On 10/1/07, Jesper Kjr Hansen <> wrote:
> I think I know the answer to this one, but just to be sure:
> Is there any formal procedure/option/returned result for identifying the exact number
> of observations a graph is based on, documented or otherwise... besides first
> principles using -count- -sum- and others, that is.
> For example:
> -count if !mi(<all vars used in graph>) & [if statement | in range]-
> The solution works well, but sometimes I can't help thinking that the graph command
> should return the number of observations used - just like an estimation command.
> /Jesper

*   For searches and help try:

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