Bookmark and Share

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]

st: R: on counting and fractions in stata


From   "Carlo Lazzaro" <carlo.lazzaro@tin.it>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: R: on counting and fractions in stata
Date   Thu, 27 Oct 2011 14:11:33 +0200

Dear Rado,
I do hope that the following code (in Stata9.2/SE) can help:
-------------------------------------------------------
set obs 10
g y=10*uniform()
g threshold=3
g threshold_exc=1 if y> threshold
replace  threshold_exc=0 if  y<=threshold
sum  threshold_exc
-------------------------------------------------------

Kindest Regards,
Carlo
-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di
rado645-bg@yahoo.de
Inviato: giovedì 27 ottobre 2011 13.39
A: statalist@hsphsun2.harvard.edu
Oggetto: st: on counting and fractions in stata

Dear all,

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)



Many thanks in advance.

Rado


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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index