Announcement

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

  • Ignoring/skipping first row in Import Excel?

    Hi All,

    Is there a way to skip over the first row (my variable names are in the second row) when importing an Excel sheet? I'm looking for an option similar to "skip" in R.

    I know I could do it with this solution (http://www.statalist.org/forums/foru...rt-excel-issue), but that seems unnecessarily complicated for my problem. I imagine there is a very simple solution to this that I'm missing.

    Thanks,
    Krista

  • #2
    Add the following option to your -import excel- command:

    Code:
    cellrange(A2:end)
    where "end" is the last cell of your data.

    Comment


    • #3
      Is there a way to find end for a given file? I'm doing this in a loop of about a hundred.

      Comment


      • #4
        If you run -import excel- with the -describe- option, Stata will examine the Excel file and will store the names and cell ranges of each worksheet in r(worksheet_1), r(range_1), etc. So you can work it from there.

        But, if your only concern is reading in the data and skipping over the first row, just use -cellrange(A2)-. The end of the range is optional, and if not specified, Stata will detect it automatically. The end of the range is really only needed if you want to exclude stuff that is beyond the range you specify.

        Comment


        • #5
          Thank you! I used cellrange(A2) and it worked perfectly.

          Comment

          Working...
          X