Hi, I am using the following loop to get the 0.5%, 1%, 2%, 5%, 95%, 98%, 99% and 99.5% percentiles for the variable "Return". However, STATA does not recognise the 0.5 and also the 99.5, I believe this is because these are not integers. Could anyone please help me, I would much appreciate this since I have been struggling for a while to get around this problem. I know I could get the 0.5 percentile and then use gen command to create my dummy variables, however I am required to use a more efficient way.
_pctile Return, percentiles( 0.5 1 2 5 95 98 99 99.5)
return list
local i = 1
foreach n of numlist 0.5 1 2 5 95 98 99 99.5 {
gen byte above`n' = Return >= `r(r`i')'
local ++i
}
Kind Regards,
Adrian
Related Posts with Calculating percentiles in STATA
predicted values from repeat regression model differentHello, I ran a OLS regression model with 59,000,000 observations and 1000+ plus variables. When I …
drop observationspost should be deleted …
What is the difference between" i.county|trend " and " i.county##c.trend "?In the process of learning the code, I found this way of writing: "i.county|trend" (county is the co…
Year fixed effects in panel datai am using panel data from 1990 to 2017 for 43 countries. I have two alternate dependent variables "…
drop observationsHello everyone, I want to drop the following observations: If a person has written several articles…
Subscribe to:
Post Comments (Atom)
0 Response to Calculating percentiles in STATA
Post a Comment