Announcement

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

  • Using import delimited and keeping variable names

    Hello,

    I have a question on keeping variable names with the import delimited command. I am running Windows and using Stata 15.1.

    This one might be an elementary question. I input my data in csv mode and it does not save the variable name, but instead creates v1, v2, v3.
    How can I make it use the variable name in the first row of my csv? Thank you.

  • #2
    Originally posted by Michael Walters View Post
    How can I make it use the variable name in the first row of my csv? Thank you.
    Use the varnames() option.
    Code:
    import delimited <file name>, varnames(1)

    Comment


    • #3
      Some such things are easier to figure out with the interactive interface which then gives you the statements to put in an do file. So if you click file - import -excel spreadsheet, or for csv the third click is on csv, variable names in first row is one of the options. Naturally, this doesn't take care of those who create spreadsheets with multiple lines of text at the top before the data.

      I often find it easier to point-and-click to obtain the full directory listing when opening all kinds of data - takes care of the problem of typing a long directory/subdirectory/subdirectory/filename or whatever. Then I can dump the long listing into my do file for next time.

      Comment


      • #4
        That's a good idea, Phil. Thank you

        Comment

        Working...
        X