Hello,

Recently I've been having a lot of trouble with local macros, especially when using them for loops. I don't see what I'm doing wrong as I have used loops and local macros successfully numerous times in the past. Here's the code from my do file:

Code:
 clear
 cls
 
 local input "C:\Users\~\Dropbox\Data"
 cd "$input"
 
 * 2002 Data
 
 local statelist AP MH
 foreach x of local statelist {
  import delimited "$input\2002\`x'\`x'_2002_AgData.csv", delimiter(comma)
  replace locid = trim(locid)
  save `x'_2002_AgData, replace
  
  clear
  
  import delimited "$input\2002\`x'\`x'_2002_ManufacData.csv", delimiter(comma)
  replace locid = trim(locid)
  save `x'_2002_ManufacData, replace
  
  clear
  
  use `x'_2002_AgData
  merge m:m locid using `x'_2002_ManufacData
  drop _merge
  save `x'_2002_AgManufac, replace
  
  }
which returns


file C:\Users\~\Dropbox\Data\2002_2002_AgData.csv not found
I don't understand why Stata is interpreting `x' to be 2002 rather than AP/MH. This is just one example of some problems I've been having with macros lately. Does anyone have an idea as to what I did wrong?

Thank you!