Looping through a list of strings; combining variables within strings

17 May 2019, 12:19

Hi everyone,
I have a series of household consumption datasets, each for every year, and I want to process each file a bit before merging them with other files.
I have two issues (examples follow bellow):
1. "use" command: it works when I explicitly state the file name, but not when I try to include a local variable in the path.
2. looping through a list of strings: this might be due to issue 1#, but I can't manage to define a list of strings - or an "an array of strings" in other programing languages - and loop through them.

To emphasize issue 1#, the following code didn't work (I got r(111): "f477fam_1997 not found") but using the explicit file path "${data}raw\households\f477fam_1997.dta" does work.
(I tried putting hshall values in qoutes but it didn't work as well..)

This issue has agonized me for long time, although it honestly seems so trivial. I tried substantive googling but to no avail.
Thanks a lot!