Dear all,

I am trying to find a way to store vector of mean estimates as scalars. In fact, I compare mean of some variables over sex and what I need is to store matrixes produced by command mean as scalars for exact male and female. Any suggestion is appreciated.

Data
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(age edu sex)
73 3 1
60 3 0
61 3 0
65 1 1
75 0 1
82 0 1
80 0 1
65 3 0
83 3 0
79 3 1
81 0 1
60 3 0
66 2 1
71 2 0
81 3 0
61 3 1
71 0 0
69 3 1
81 0 1
69 0 1
78 2 0
62 3 1
62 2 1
75 0 0
70 3 0
84 0 1
82 3 1
63 1 1
87 0 1
80 1 0
70 3 0
75 0 1
60 2 1
61 1 1
66 2 0
73 1 1
60 2 0
83 0 1
64 0 1
67 0 1
81 0 1
75 1 1
74 3 1
63 0 1
82 3 1
61 3 1
66 3 0
73 2 1
82 3 0
81 2 1
82 0 0
74 3 0
67 3 0
73 3 0
62 1 1
65 2 0
61 1 1
86 0 1
80 0 1
62 0 1
76 0 1
71 1 1
66 3 1
63 3 0
72 3 0
84 0 1
70 1 0
81 0 1
60 3 1
66 3 1
65 0 0
75 0 1
81 0 1
61 3 1
85 0 1
70 1 1
72 3 1
61 2 0
76 3 0
63 3 0
66 3 0
86 3 0
82 0 1
82 1 0
64 1 1
61 2 0
73 0 1
72 1 0
84 0 0
79 0 1
81 3 0
66 3 1
75 1 1
61 3 0
63 2 1
62 3 0
79 3 0
61 1 1
81 3 0
71 3 0
end
label values edu edu
label def edu 0 "No schooling/incompleted primary school", modify
label def edu 1 "Primary school", modify
label def edu 2 "Secondary school", modify
label def edu 3 "High school and above", modify
label values sex sex
label def sex 0 "Male", modify
label def sex 1 "Female", modify
I know how to scalar results for each groups separately without option -over-, but I still do not find a way to do so using option -over-
Code:
* codes to store results for each group without using option -over-
global X "age edu"

foreach x of global X {
    qui {
* For Male
        mean $X if sex==0
        mat b`x' = e(b)
        mat b_`x' = b`x'[1,"`x'"]
    *Sca mean of $X
        sca mb_`x' = b_`x'[1,1]

* For female
        mean $X if sex==1
        mat b`x' = e(b)
        mat b_`x' = b`x'[1,"`x'"]
    *Sca mean of $X
        sca fb_`x' = b_`x'[1,1]
}
    sca di mb_`x' fb_`x'
    }
Thanks!