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

st: RE: RE: Percent of time a

From   Howard Lempel <>
To   "" <>
Subject   st: RE: RE: Percent of time a
Date   Tue, 10 Feb 2009 15:45:57 -0500


My language was imprecise.  I do not have a time series, but rather want to know in what proportion of weighted observations my condition holds.  

That being said, -_gwtmean- does do what I want, albeit by creating an extra variable, which is easy enough to drop.


-----Original Message-----
From: [] On Behalf Of Nick Cox
Sent: Tuesday, February 10, 2009 3:24 PM
Subject: st: RE: Percent of time a

I interpret this as meaning that you have time series data with
regularly spaced observations. If that's not true, what follows will
need modification. 

You need a weighted mean of an expression that would produce an
indicator variable. David Kantor's _gwtmean function for -egen- from SSC
will do that, but I don't know a command that will do this without
generating a new variable, but it's programmable. 


Howard Lempel

Is there a command that will give me the proportion of the time a
variable is equal to a certain value?  The command must accept weights.
I'm looking for something like -tabcond-, from SSC, but that returns
proportions as well as counts.

One option would be to -generate- a dummy equal to 1 when my variable is
equal to my value and zero otherwise and then to use -svy: mean-, but I
would prefer something that can be done in one line (and without
generating a new variable).  My variable is continuous, so I don't want
to -svy: tab- the whole thing.

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index