Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"rado645-bg@yahoo.de" <rado645-bg@yahoo.de> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: RE: RE: RE: on counting and fractions in stata |

Date |
Fri, 28 Oct 2011 18:14:18 +0100 (BST) |

Dear Nick, thanks a lot for helping me resolve this problem. I have one quick question:do you believe it is possible to carry out this estimation in Stata at once for more than one series of observations. I can sort my data for example in the following way (in each column - the first value corresponds to the threshold value followed by the daily observations): column1 column2 column3 threshold1 threshold2 threshold3 series 1 series 2 series 3 I guess I should tell Stata in a first place to refer to the first value in each column as the threshold. Then - to compare with the rest of the observations in this column only; and report the number of cases in which the threshold value is crossed as well as the percentage share of these cases. Third - to tell Stata to move to the next column. Do you believe this is doable in Stata language? Best, Rado ----- Ursprüngliche Message ----- Von: Nick Cox <n.j.cox@durham.ac.uk> An: "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> Cc: Gesendet: 14:18 Donnerstag, 27.Oktober 2011 Betreff: st: RE: RE: RE: on counting and fractions in stata You can naturally also go gen byte above = series > 3.1 su above, meanonly local mean = r(mean) local total = r(N) local count = r(sum) and any extra conditions can be put on the -summarize-. In each case, "series > 3.1" would in careful code be "series > 3.1 & series < ." Nick n.j.cox@durham.ac.uk -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 27 October 2011 13:07 To: 'statalist@hsphsun2.harvard.edu' Subject: st: RE: RE: on counting and fractions in stata If you have other conditions, the pattern is count if series > 3.1 & <condition) local count = r(N) count if <condition> local total = r(N) local fraction = `count'/`total' Nick n.j.cox@durham.ac.uk Nick Cox . 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 n.j.cox@durham.ac.uk rado645-bg@yahoo.de 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/ * * 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/ * * 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/

**Follow-Ups**:**RE: st: RE: RE: RE: on counting and fractions in stata***From:*Nick Cox <n.j.cox@durham.ac.uk>

**References**:**st: on counting and fractions in stata***From:*"rado645-bg@yahoo.de" <rado645-bg@yahoo.de>

**st: RE: on counting and fractions in stata***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: RE: RE: on counting and fractions in stata***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: RE: RE: RE: on counting and fractions in stata***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: ologit on MAC question** - Next by Date:
**st: RE: ologit on MAC question** - Previous by thread:
**st: RE: RE: RE: on counting and fractions in stata** - Next by thread:
**RE: st: RE: RE: RE: on counting and fractions in stata** - Index(es):