0

Stata version: 12.1

I get an error "file not found" using this code:

cd "$path_in"
insheet using "df_mcd_clean.csv", comma clear
    append using "df_mcd15_clean.csv" #where error happens
    append using "df_ingram_liu1998_clean.csv" 
    append using "df_wccd_clean.csv"

I double checked that the file is indeed called that and located in the directory.

Nick Cox
  • 35,529
  • 6
  • 31
  • 47
Victor Nielsen
  • 443
  • 2
  • 14
  • See detailed solution to similar issue here: https://stackoverflow.com/questions/70958836/file-csv-not-stata-file-error-in-using-merge-command/70961450#70961450 – TheIceBear Feb 07 '22 at 16:18

1 Answers1

1

append is for appending .dta files. Therefore, if you ask to append foo.csv Stata assumes you are referring to foo.csv.dta, which it can't find.

The solutions include

  1. Combine the .csv files outside Stata.

  2. Read in each .csv file, save as .dta, then append.

The current version of the help for append says this:

append appends Stata-format datasets stored on disk to the end of the dataset in memory. If any filename is specified without an extension, .dta is assumed.

and that was true too in Stata 12. (Whether the wording was identical, you can say.)

Nick Cox
  • 35,529
  • 6
  • 31
  • 47
  • My stata version doesn't accept dta files unfortunately. When I try to use one, it says it's an invalid format. That's why I converted it to csv. Is not not possible to use append in any way with a csv? – Victor Nielsen Feb 07 '22 at 15:54
  • 1
    If that's true, your version of Stata is badly broken. What you mean, I imagine, is more specific: your version of Stata can't read in .dta files created with a later specification. What I said is absolute: `append` won't accept .csv files, as you found, and route #2 is the main answer for you. – Nick Cox Feb 07 '22 at 15:58
  • Then it's probably dta files from a newer version. I will try to reconvert. – Victor Nielsen Feb 07 '22 at 16:46
  • If `sysuse auto` works in your Stata, it can read .dta files. – Nick Cox Feb 07 '22 at 16:59