Announcement

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

  • Specifying name of each output dta file when using xls2dta, allsheets

    Hi, I am trying to import multiple sheets from an excel file but am struggling to specify the name of the outputted dta files. I want each dta file to be saved as the sheet name in the imported excel file.

    Here is my code:

    Code:
    xls2dta, allsheets : import excel using "bdnf_all.xlsx", firstrow
    This code imported each sheet but saved them as file_x.dta (where x = sheet number).

    I was also wondering whether I can use the replace option?

    Many thanks,
    Liz


  • #2
    The official import excel has a -describe- option. You can retrieve the sheet names from stored results in r() and write a loop that imports and saves each sheet at a time. I don't use xls2dta (from SSC, as you are asked to explain), so you may get a better answer from those familiar with that command.

    Code:
    clear
    qui import excel using myfile.xlsx, describe
    return list

    Comment


    • #3
      Thank you!

      Comment

      Working...
      X