04-02-2013 06:01 PM
Hi, I'm trying to calculate the statistics: minimum; 1 , 25 , 50 , 75 ,and 99 percentiles; maximum; and standard deviation which are the time-series averages of monthly cross-sectional statistic over the 12 month of each year. I'm using the following codes
proc means data=data_in min P1 P25 P50 P75 P99 max std;
output out = data_out mean= min= P1= P25= P50= P75= P99= max= std= /autoname;
But it just give me the actual quantile of the time-series data instead of the average of those quantile, in other word I would like to have the time-series average of the 50 percentile is the same as the mean of the time-series. My data are the time-series return data of more than1000 different stocks.
Thanks a lot in advance!
04-03-2013 10:03 AM
The code computes the statistics for MRET each unique YEAR value. Are you saying that you want the average of the statistics over the various years? If so, run PROC MEANS a second time:
proc means data=data_out mean;
04-03-2013 10:37 AM
I would like to have the results like this. And the 50 percentile would be the same as the means of the cross-sectional time-serie data in that year. (N is the number of different stocks)
04-03-2013 10:49 AM
50th percentile is the median not the mean. For it to match the mean you need an exactly normal distribution, which is not likely.
You've shown what you want the results to look like, what results are you getting and what does your data look like.
04-03-2013 11:13 AM
Indeed I have for 50th percentile the median, not the mean. My results looks like this (with freg is the number of observations in that year). so those percentile are not the average of the percentiles themselves.
the results are the same for "CLASS year" and "BY year"
04-03-2013 11:51 AM
The data that i have are the time-series data of monthly stocks return. The number of stocks varies per years from 100-800, there are in total more than 1000 stocks. I would like to have the time-serie averages of monthly cross-sectional statistics of those return over the 12 months of each year exactly like the one above.
But e.g. for the time-series average of the 50th percentiles in year 1980 I would like to have 4.1060 ( the mean) instead of 3.8642 (the median).
04-03-2013 12:17 PM
Sorry, it's still not clear to me.
If you want mean, specify mean= instead of p50=
Other than that you'll need to provide more details, sample input and sample output would be preferable.
04-19-2017 02:43 PM
hi, i am trying to do simialr thing. Can u please let me know how you have done it in SAS.
For reference, I m trying to calculate time series averages of cross-sectional means, medians, Standard deviations.