Announcement

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

  • import excel

    I want to import a data from an excel sheet and I want all the variables to be in the format as doubles I wonder if this is possible to do using the command import excel. I know this is possible with the command import delimited however the excel sheet I am working with has multiple sheets and the command import delimited doesn't have a sheet() option.

  • #2
    For columns stored as floating-point numeric data in an Excel workbook, I believe that the default datatype for -import excel- is double. If you want to convert numeric data that are integers in the worksheet, then you can do so afterward using -recast-.

    Code:
    sysuse auto, clear
    
    ds , has(type float)
    
    export excel using Dummy.xlsx, sheet(Auto) firstrow(variables)
    
    drop _all
    import excel using Dummy.xlsx, sheet(Auto) firstrow
    ds , has(type float)
    ds , has(type double)
    
    // Here:
    ds , has(type byte int)
    recast double `r(varlist)'
    ds , has(type double)
    
    erase Dummy.xlsx

    Comment

    Working...
    X