Announcement

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

  • Invalid name error

    So I am trying to upload a .csv file into Stata, but when I run it, it gives me an 'Invalid name' error message r(198). I am using Stata 14.2. This seems like a simple problem to fix, but even after renaming the file and saving it again, I still get the same error message.

  • #2
    you need to show us what you typed into Stata; please follow the advice in the FAQ and post between CODE delimiters

    Comment


    • #3
      Welcome to Statalist.

      In the absence of seeing what command you ran and of seeing the first few lines of your csv, I'm limited to guessing. My guess is that on your import delimited command you have specified variable names for the imported columns of data, and one ore more of those variable names is not a valid Stata variable name.
      Code:
      . type example.csv
      id,age,2015,2016
      101,12,42,666
      
      . import delimited using example.csv, clear varnames(1)
      (4 vars, 1 obs)
      
      . list, clean noobs
      
           id   age   v3    v4  
          101    12   42   666  
      
      . import delimited id age 2015 2016 using example.csv, clear varnames(1)
      2015: invalid variable name
      r(198);
      
      . import delimited id age v2015 v2016 using example.csv, clear varnames(1)
      (4 vars, 1 obs)
      
      . list, clean noobs
      
           id   age   v2015   v2016  
          101    12      42     666  
      
      .

      Comment

      Working...
      X