Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: R: on counting and fractions in stata

From   "Carlo Lazzaro" <>
To   <>
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,
-----Messaggio originale-----
[] Per conto di
Inviato: giovedì 27 ottobre 2011 13.39
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

Given this data,I would like to get the following estimates (comments in

count:1 (threshold is exceeded only once)
fraction: 1/4=0.25 (one out of 4 cases)

Many thanks in advance.


*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index