Announcement

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

  • Appending multiple files with a loop

    I need to append multiple files. This is what I have:
    Code:
    foreach i in ENTRATE USCITE {
    2. use tempfile entrate_o_uscite
    3. forvalues y=2010/2022 {
    4. append "$base\data\\`i'_`y'.dta"
    5. collapse (sum) IMP_`i'_ATT, by(x)
    6. }
    7. save "$base\SIOPE\intermediate\\`i'.dta", replace
    8. }
    The result is:
    Code:
    invalid 'entrate_o_uscite'
    How do I fix this?

  • #2
    If you save a tempfile

    Code:
    tempfile entrate_o_uscite
    save `entrate_o_uscite'
    you refer to it subsequently as

    Code:
    use `entrate_o_uscite', clear

    Comment


    • #3
      I use some variant of this code to accomplish this, whenever I have to do this

      Comment

      Working...
      X