Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: assigning a name to the output of -count-

From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: Re: assigning a name to the output of -count-
Date   Sun, 2 Jan 2005 09:37:54 -0500

In addition, you might want to look at my recent posting statalist.0412/date/article-797.html

which discussed how to make use of results of r(count).

Kit Baum, Boston College Economics

On Jan 2, 2005, at 2:33 AM, statalist-digest wrote:

Dear Stata users,

I would like to count the number of missing observations in a variable
-var1- of my dataset and perform cetain operations based on the count.
To do this I entered
count if var1 == .
and  I get a number, lets say 40: However, when I wanted to compare
the output of count (here 40) with another number such that:
if count <=50 {....

I receive error message saying that stata could not find count. How
can I assign a name to the output of the count command?

thanks a lot
If you do -return list- after the -count- command, you'll see that the
value computed by -count- is stored in r(N).  So, do something like

count if missing(var1)
if r(N) <= 50 {...
*   For searches and help try:

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