Announcement

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

  • Beginner User: invalid variable r(198)

    Hi All-

    Each time I run the code below, I receive an invalid 'data' r(198) response from STATA. I am using the updated STATA 17. What am I doing wrong? How can I fix this?



    *Import and append all data from dta

    *set the local space where you saved the dta file

    global all_dta "/Users/emmaposey/Downloads/dta"
    cd "$all_dta"

    *import and append all data from dta

    * Create a temp file to append all files to. This will become the main dataset.
    tempfile data
    save 'data', emptyok

    *import all datasets and append:
    local filenames : dir "${all_dta}" files "*.dta"

    foreach f of local filenames {

    use `"`f'"', clear // import file

    gen source_dta = `"`f'"' // create variable with name file
    }

  • #2
    You need a left (opening) single quote in

    Code:
    save `data', emptyok
    Please use CODE delimiters as here to show code. It is much easier to read that way.

    Comment

    Working...
    X