Announcement

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

  • the sheet("sheetname") option of import excel command: once upon a time?

    Hi, specialists.Well, I 'm trying to import .xls files with multiple worksheets named like 1,2,3 ``` until 10. when I simply want to import it with command like import excel with sheet option with these sheetnames, the stata gave me the error message
    my code is just like
    local sh_name "1 2 3 4 5 6 7 8 9 10"
    import excel region=A area=D tran_value=F ///
    using land_granting_y2007.xls ,sheet("`sh_name'") cellrange(A12:G50)

    and the error message is like
    worksheet 1 2 3 4 5 6 7 8 9 10 not found
    r(601);

    so I wonder if the sheetname can only use one sheetname upon once a time? Do i have to use some author written command like "xls2dta"?

  • #2
    I believe that you'll need to import each worksheet separately (in a loop) and concatenate them. There are numerous threads (with example code) on how to do this.

    Comment


    • #3
      Also see xls2dta (SSC) for the importing-part. It leaves behind the number of files created and their names, so these can be used in subsequent loops, combined with merge or append.

      Best
      Daniel

      Comment

      Working...
      X