Announcement

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

  • Epxorting data to excel

    Can I export data to excel including variable name in the first row and label in the second row, and how is this done?

  • #2
    I assume from the wording of your question that you are familiar with the export excel command. What I have done to bend it to my will is something like the following.
    Code:
    export excel ..., sheet(sheetname, replace) firstrow(variables) cell(A1)
    export excel ..., sheet(sheetname, modify)  firstrow(varlabels) cell(A2)
    The first export writes the variable names in row 1 followed by the data. The second export leaves row 1 unchanged and below it overwrites the data (with the variable labels in row 2 and the data following.

    It's a hack, but it's a convenient hack.

    Comment


    • #3
      You want to issue two export excel commands, specifying the cell() option not to overwrite the output of the first command

      Code:
      sysuse auto, clear
      preserve
      drop in 1/l
      set obs 1
      export excel myfile.xlsx, sheet("one") first(var) 
      restore
      export excel myfile.xlsx, sheet("one", modify) first(varl) cell(A2)

      Comment

      Working...
      X