su abnormal_return if dif < -4
gen std_dev = r(sd)
Nick
[email protected]
mai mai
> I need to create a variable that is the standard deviation of another
> variable from a certain range of data. However, I need this standard
> deviation to be created for all the observations. That is, I have the
> following data, I want to calculate std_dev as the standard deviation
> of the abnormal_return if dif<-4, but I want that standard dev to be
> pasted for all rnages of difs...like this (where the 1.58 is the
> standard deviation for abnormal_return data for the first 5
> observations):
>
> obs# dif abnormal_return std_dev
> 1 -9 2.3 1.58
> 2 -8 2.2 1.58
> 3 -7 3.3 1.58
> 4 -6 5.3 1.58
> 5 -5 1.1 1.58
> 6 -4 2.3 1.58
> 7 -3 2.3 1.58
> 8 -3 2.3 1.58
> 9 -1 2.3 1.58
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/