Hi,
i need to export many summary tables to excel. In these summary tables I need to have the highest and second highest value of a variable grouped by another variable.
For example:

sysuse auto
tabstat price, statistics(mean sd p25 p50 p75 p90 count max min) by(foreign)

Unfortunately, there is no "statistic" in the tabstat option to specify that I need not only the max but also the second highest value.

I know that there are ados like "extremes" but I really need summary statistics (mean, sd, quantiles and the two highest values) in one table (because I need to export >100 tables in total).

Do you have any ideas how I can get a table such as with tabstat and the by option plus the two highest values?

Thanks a lot in advance!