Dear Stata experts,
I have a dataset including company returns over 16 years and want to graphically describe them using a graph with the yearly mean of company returns as well as some percentiles to give an additional indication of the distribution of the values. I added an image below to underline what should be displayed. I found calculating the mean easy, but did not find a way to calculate the yearly percentiles (ideally using an additional if condition to select one specific country).
I am new to stata and managed to develop the following code so far. Can I somehow export those values to Excel and use them there, or even save and add those percentiles calculated into a graph in stata?
Output:
2014
variable | N p50 p25 p75
-------------+----------------------------------------
RoA | 74 .7773741 .2041142 1.163145
------------------------------------------------------
2015
variable | N p50 p25 p75
-------------+----------------------------------------
RoA | 69 .866985 .366647 1.258994
------------------------------------------------------
2016
variable | N p50 p25 p75
-------------+----------------------------------------
RoA | 68 1.039269 .4520355 1.403584
------------------------------------------------------

Thank you a lot for the support and sharing your knowledge!
I have a dataset including company returns over 16 years and want to graphically describe them using a graph with the yearly mean of company returns as well as some percentiles to give an additional indication of the distribution of the values. I added an image below to underline what should be displayed. I found calculating the mean easy, but did not find a way to calculate the yearly percentiles (ideally using an additional if condition to select one specific country).
I am new to stata and managed to develop the following code so far. Can I somehow export those values to Excel and use them there, or even save and add those percentiles calculated into a graph in stata?
forval Year=2000(1)2016 {
display `Year'
tabstat RoA if Year==`Year'&country=="DK", statistics(count p50 p25 p75)
}
display `Year'
tabstat RoA if Year==`Year'&country=="DK", statistics(count p50 p25 p75)
}
2014
variable | N p50 p25 p75
-------------+----------------------------------------
RoA | 74 .7773741 .2041142 1.163145
------------------------------------------------------
2015
variable | N p50 p25 p75
-------------+----------------------------------------
RoA | 69 .866985 .366647 1.258994
------------------------------------------------------
2016
variable | N p50 p25 p75
-------------+----------------------------------------
RoA | 68 1.039269 .4520355 1.403584
------------------------------------------------------
Thank you a lot for the support and sharing your knowledge!
Comment