Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: on counting and fractions in stata
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: on counting and fractions in stata
Date
Thu, 27 Oct 2011 12:53:34 +0100
. count if series > 3.1
. local count = r(N)
. local total = _N
. di `count'
. di `total'
. di `count'/`total'
-count- is a much-overlooked command. People seemingly don't find it or think it too simple. See e.g.
SJ-7-1 pr0029 . . . . . . . . . . . . . . . Speaking Stata: Making it count
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q1/07 SJ 7(1):117--130 (no commands)
discusses count used with a loop over observations
or variables
SJ-7-4 dm0033 . . . . . . Speaking Stata: Counting groups, especially panels
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q4/07 SJ 7(4):571--581 (no commands)
discusses how to count panels through reduction commands
or through tabulation commands and how to overcome
problems that do not yield easily to these approaches
Nick
[email protected]
[email protected]
I face the following problem in Stata:
I have a series of daily observations on a given variable and I also have one estimate of this variable that serves as a threshold.
I would like to estimate how many times this threshold is exceeded by comparing the value of this estimate with the available data on daily observations. Is it possible to estimate fractions in Stata in this particular way?
Below is a simple example:
series estimate: 3.1
1.2
2.1
3.2
1.01
Given this data,I would like to get the following estimates (comments in brackets):
count:1 (threshold is exceeded only once)
fraction: 1/4=0.25 (one out of 4 cases)
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/