Hello,

I am trying to run a z-test on the mean of a variable of a portfolio (top 10 percent of an index) compared to the mean of a benchmark (the index).
The portfolio is created using a binary variable with a 1 if it is a part of the portfolio and otherwise 0, this column is being called PB10.
Using the command; ztest gendivY, by(PC10) - the following output is presented

ztest gendivY, by(PB10)


Two-sample z test
------------------------------------------------------------------------------
Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---------+--------------------------------------------------------------------
0 | 536,150 22.02248 .0013657 1 22.0198 22.02516
1 | 60,132 27.14717 .004078 1 27.13918 27.15516
---------+--------------------------------------------------------------------
diff | -5.12469 .0043006 -5.133119 -5.116261
------------------------------------------------------------------------------
diff = mean(0) - mean(1) z = -1.2e+03
Ho: diff = 0

Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
Pr(Z < z) = 0.0000 Pr(|Z| > |z|) = 0.0000 Pr(Z > z) = 1.0000

In this test the portfolio(1) is compared to the rest (the 0), but not compared to the benchmark which would be PB10(1+0). Is there any way in which I can run a z-test testing the portfolio against the whole benchmark?

Thank you very much in advance!