Hi everyone,

The whole file is attached below
How can I calculate the average value for DM Age colume of each company, the proportion of females and reshape wide to long format?
I tried to attach id for each company by using the command: egen company_id = group (BvD ID number) but the order of companies then changed -> is it ok?
I use the command bysort companyname: egen average_age = mean(Age) after encode the variable DMAge but it doesn't work.

Thank you
Company name BvD ID number Operating revenue (Turnover)
th EUR
2015
Operating revenue (Turnover)
th EUR
2016
Operating revenue (Turnover)
th EUR
2017
Number of directors & managers DM
Age
DM
Gender
1. NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 77 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 67 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 67 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 67 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 67 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 68 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 68 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 68 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 68 M
NESTLÉ S.A. CHCHE105909036 82,665,557 84,259,512 77,466,693 163 67 M
ROCHE HOLDING AG CHCHE101602521 46,665,159 49,148,191 47,659,316 80 63 M
ROCHE HOLDING AG CHCHE101602521 46,665,159 49,148,191 47,659,316 80 63 M
ROCHE HOLDING AG CHCHE101602521 46,665,159 49,148,191 47,659,316 80 63 M
ROCHE HOLDING AG CHCHE101602521 46,665,159 49,148,191 47,659,316 80 63 M
ROCHE HOLDING AG CHCHE101602521 46,665,159 49,148,191 47,659,316 80 60 F
ROCHE HOLDING AG CHCHE101602521 46,665,159 49,148,191 47,659,316 80 63 M
ROCHE HOLDING AG CHCHE101602521 46,665,159 49,148,191 47,659,316 80 M
ROCHE HOLDING AG CHCHE101602521 46,665,159 49,148,191 47,659,316 80 61 M
3. NOVARTIS AG CHCHE103867266 48,163,868 48,726,896 43,445,359 140 66 M
NOVARTIS AG CHCHE103867266 48,163,868 48,726,896 43,445,359 140 66 M
NOVARTIS AG CHCHE103867266 48,163,868 48,726,896 43,445,359 140 70 M
NOVARTIS AG CHCHE103867266 48,163,868 48,726,896 43,445,359 140 64 F
NOVARTIS AG CHCHE103867266 48,163,868 48,726,896 43,445,359 140 71 F
4. SOCAR TRADING SA CHCHE113990112 n.a. n.a. n.a. 13 56 M
SOCAR TRADING SA CHCHE113990112 n.a. n.a. n.a. 13 44 M
SOCAR TRADING SA CHCHE113990112 n.a. n.a. n.a. 13 44 F
SOCAR TRADING SA CHCHE113990112 n.a. n.a. n.a. 13 62 M
SOCAR TRADING SA CHCHE113990112 n.a. n.a. n.a. 13 62 M
5. COOP-GRUPPE GENOSSENSCHAFT CHCHE109029938 24,934,747 26,445,305 24,970,144 71 66 M
COOP-GRUPPE GENOSSENSCHAFT CHCHE109029938 24,934,747 26,445,305 24,970,144 71 57 M
COOP-GRUPPE GENOSSENSCHAFT CHCHE109029938 24,934,747 26,445,305 24,970,144 71 57 M
COOP-GRUPPE GENOSSENSCHAFT CHCHE109029938 24,934,747 26,445,305 24,970,144 71 57 M