Announcement

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

  • Issue with importing data

    Hi all,

    Sorry if my question may seem basic but unfortunately I wasnt able to find a solution anywhere.

    I have data in an excel sheet (xlsx) in several tabs which I would like to import into stata. I am using the following command to import asset prices:

    import excel "C:\Users\....\data.xlsx", sheet("Price") firstrow

    The problem is that after imported in stata, its treating it as a string and not a number. I see variable type is "str17" and format "%17s" whereas I believe it should be "double". Where is this problem coming from? Must I somehow format my excel sheet to start with? Probably related to this issue, often a number such as 72.34 in excel appears as 72.34000000000001 once in stata.

    many thanks,
    Marc

    Last edited by Marc Cavin; 24 Apr 2017, 14:23.

  • #2
    Welcome to the Stata Forum.

    You may either check it out in Excel, before importing, or take a look in Stata.

    In short, shall an observation have, say, something different then raw numbers, Stata will import the vRiable as string.

    For further advice, it would help to follow the FAQ, particularly om how to share command and output.
    Best regards,

    Marcos

    Comment


    • #3
      Originally posted by Marc Cavin View Post
      Probably related to this issue, often a number such as 72.34 in excel appears as 72.34000000000001 once in stata.
      This is explained here:
      Code:
      help precision
      Demonstration of this issue:
      Code:
      . clear
      . set obs 1
      . gen test = 72.34
      . di test[1]
      72.339996

      Comment

      Working...
      X