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
Append multiple files based on variable conditionsHi, I have a lot of datasets to append, but Stata runs out of memory as the files are large contain…
outreg2Hello, I have a question regarding exporting the Stata table using outreg2. The following is my cod…
npgraph, post estimation command for npregressHi everyone, Hope you are doing great. So I'm currently working with the command npregress and want…
DiD after psmatch2Dear all, I want to perform a DiD regression but as my treatment was not randomly assigned, I am us…
interpretation of margins from probit modelHi, I obtained the following results usin margins on a probit model Code: Regression model to measu…
Subscribe to:
Post Comments (Atom)
0 Response to Calculating percentiles in STATA
Post a Comment