Announcement

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

  • Importing csv

    Hi,

    I have an easy problem, but unfortunately I could not solve it.

    When I want to import data from excel and the first row to be the name of the varibales I use this comand in the do file:

    import excel using Data, firstrow clear

    I want to do the same witha data saved as csv. I use the comand:

    import delimited "data.csv", delimiter(";") clear

    but I do not know how to put row1 instead of v1,v2, ect. , so that instead v1 there is user_id_august, instead v3 part_real-august, ect.



    Thanks.



  • #2
    This is documented in the help for import delimited. The option is -firstrow()-.

    Comment


    • #3
      Originally posted by Leonardo Guizzetti View Post
      This is documented in the help for import delimited. The option is -firstrow()-.
      Hi Leonardo,

      I have tried several codes (combinations with firstrow), but I get always error. Could you please write the code down for my example import delimited "data.csv", delimiter(";") clear
      Thanks.


      Comment


      • #4
        In -import delimited- the option is not -firstrow()-, it is -varnames()- and you specify which row of the input provides the variable names. Assuming your .csv file has the variable names in the first row, it would be
        Code:
        import delimited using data.csv, delimiter(;) varnames(1)
        Leonardo Guizzetti is, however, correct in saying that you can find this information yourself in the help file.

        Comment


        • #5
          Thanks for the clarification Clyde. I knew it was there but wasn't at my computer to check.

          Comment

          Working...
          X