Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • export tables to excel

    Hello everyone,
    for my descriptive statistics I want to generate tables which show the mean of each ESG score for all companies per year, ending up in a table with 2 rows: year (2016-2022) and mean values and export those to excel.
    I used following commands to generate the mean variables and to table them in stata:

    bysort Year: egen ESGmeanperyear = mean(ESGScore)
    bysort Year: egen Envmeanperyear = mean(EnvironmentalScore)
    bysort Year: egen Socialmeanperyear = mean(SocialScore)
    bysort Year: egen Govmeanperyear = mean(GovernanceScore)
    bysort Year: egen ESGCombmeanperyear = mean(ESGCombinedScore)
    bysort Year: egen ESGContrmeanperyear = mean(ESGControversiesScore)

    tabstat ESGmeanperyear, by(Year)
    tabstat Envmeanperyear, by(Year)
    tabstat Socialmeanperyear, by(Year)
    tabstat Govmeanperyear, by(Year)
    tabstat ESGCombmeanperyear, by(Year)
    tabstat ESGContrmeanperyear, by(Year)

    For example to convert the table of mean ESG scores to excel i tried the folllowing command, but the excel just shows the names of the rows without values:

    putexcel set Descriptives.xlsx, sheet ("MeansESG") modify
    tabstat ESGmeanperyear, by(Year)
    putexcel A1=("Year") B1=("ESGmeanperyear")
    putexcel B2=matrix(r(table))

    Does anyone know how i have to change to command to export the tables to excel?

    Thanks in advance and regards
    Constanze Losert
Working...
X