Hi I am new to the panel variables and have encountered a problem. I am using xtsum command to get the average age of patient by panel variable (which is patient ID). However, since every patient have different frequency of data I end up with mean age (accounting the different frequencies which is 67.38). However, I'd like to get mean of age without accounting for different frequencies in each patient ID - otherwise I'd like to get the real mean age of patients which is 68.78. Are there any stata commands that allow me to do that?

Thanks in advance, I put the commands that I used below.

xtsum age

Variable | Mean Std. Dev. Min Max | Observations
-----------------+--------------------------------------------+----------------
age overall | 67.38174 7.829393 52 85 | N = 2245
between | 9.028221 52 85 | n = 19
within | 0 67.38174 67.38174 | T-bar = 118.158


tab ïpatientid, sum(age)

| Summary of age
ïpatientid | Mean Std. Dev. Freq.
------------+------------------------------------
1 | 80 0 26
2 | 71 0 67
3 | 67 0 46
4 | 76 0 128
5 | 70 0 54
6 | 85 0 70
7 | 70 0 153
8 | 63 0 266
9 | 67 0 153
10 | 76 0 172
11 | 61 0 48
12 | 67 0 174
13 | 52 0 127
14 | 85 0 48
15 | 54 0 145
16 | 68 0 130
17 | 71 0 219
18 | 61 0 91
19 | 63 0 128
------------+------------------------------------
Total | 67.381737 7.8293933 2,245

display (80+71+67+76+70+85+70+63+67+76+61+67+52+85+54+68+7 1+61+63)/19
68.789474