Hello,
I have an unbalanced panel for 24 different companies with monthly data from 1995 to 2019 and 26 different variables . The data was given to me in an excel file and I've successfully imported it to Stata and defined it as a panel. My goal is to generate trimestral averages for each of the 26 variables. My intuition was to use the 'egen' command to generate the averages, however I need to generate an average for each company and the option by is not allowed when using a panel dataset. I found an sac called egenmore but I wasn't able to understand how to use it. An example of what I expect is:
For variable v1, I would like to generate trimestral averages by company.
My dofile goes like this until now:
*Dofile Provisiones
clear
import excel "/Users/nicolasmorales/Downloads/Base Bancos 11-2019.xlsx", sheet("Bancos 12-11-2019") firstrow
encode Entidad, gen(entidad)
drop Entidad
encode v44, gen(v_44)
drop v44
rename v_44 v44
rename Fecha fecha
sort entidad fecha
duplicates report entidad fecha
duplicates tag entidad fecha, gen(ind)
tab ind
drop if ind==1
gen monthly_date=mofd(fecha)
format monthly_date %tm
drop fecha
rename monthly_date fecha
xtset entidad fecha, monthly
I have an unbalanced panel for 24 different companies with monthly data from 1995 to 2019 and 26 different variables . The data was given to me in an excel file and I've successfully imported it to Stata and defined it as a panel. My goal is to generate trimestral averages for each of the 26 variables. My intuition was to use the 'egen' command to generate the averages, however I need to generate an average for each company and the option by is not allowed when using a panel dataset. I found an sac called egenmore but I wasn't able to understand how to use it. An example of what I expect is:
For variable v1, I would like to generate trimestral averages by company.
My dofile goes like this until now:
*Dofile Provisiones
clear
import excel "/Users/nicolasmorales/Downloads/Base Bancos 11-2019.xlsx", sheet("Bancos 12-11-2019") firstrow
encode Entidad, gen(entidad)
drop Entidad
encode v44, gen(v_44)
drop v44
rename v_44 v44
rename Fecha fecha
sort entidad fecha
duplicates report entidad fecha
duplicates tag entidad fecha, gen(ind)
tab ind
drop if ind==1
gen monthly_date=mofd(fecha)
format monthly_date %tm
drop fecha
rename monthly_date fecha
xtset entidad fecha, monthly
Comment