Announcement

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

  • importing a .csv file

    Hi,
    I have a .csv file that the first row is variable names and the second row belongs to the corresponding labels. I wonder to know how can I import my file into Stata such that the first row and second row are read as variable and label names, respectively!
    Thanks,
    NM

  • #2
    You could try this:
    Code:
    import delimited using path_to_csv_file, varnames(1) clear
    foreach var of varlist * {
        label var `var' `"`=`var'[1]'"'
    }
    drop in 1

    Comment


    • #3
      To the excellent advice in #2, I will just add that with this arrangement, all of the variables will have been imported as strings. So some additional work will be required on those which need to be numeric for subsequent use.

      Comment

      Working...
      X