Announcement

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

  • How to export to excel with multiple sheets

    Hi all,

    I have variables below in one dta file and I wonder if I can export these variables to one excel with many sheets.
    For example,
    sheet1: "predator"-"victim_id"+"vyr_2000"-"vyr_2023"
    sheet2: "predator"-"victim_id"+"yr_2000"-"yr_2023"
    sheet3: "predator"-"victim_id"+"sum_yr_2000"-"sum_yr_2023"


    Thank you so much!















    Attached Files

  • #2
    Yes. If you check -help export excel- you will see that it has a -sheet()- option that lets you specify the sheet you wish to export to:

    Code:
    export excel predator-victim_id vyr_2000-vyr_2023 using spreadsheet_name.xlsx, firstrow(variables) sheet("sheet1", replace)
    export excel predator-victim_id yr_2000-yr_2023 using spreadsheet_name.xlsx, firstrow(variables) sheet("sheet2", replace)
    export excel predator-victim_id sum_yr_2000-sum_yr_2023 using spreadsheet_name.xlsx, firstrow(variables) sheet("sheet3", replace)

    Comment


    • #3
      Thanks so much!

      Comment

      Working...
      X