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

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


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: assigning a name to the output of the "count"
Date   Sat, 01 Jan 2005 17:51:39 -0500

At 05:37 PM 1/1/2005 -0500, sarah smith 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
Sarah
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 {...


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc

*
* 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