I am trying to save a list of names and then loop through those names, using the code below. However, 1 or maybe 2 things seem to be going wrong.
After the first (levelsof) line, output looks (correctly) like this:
`"ABBITT, CHANCE M"' `"ABBOTT-HALL, RILEY"' `"ABDALLA, JOSEPH M"' `"ABEL, KEITH J"'...
After the second (di `names') I get this, where it looks like the double quotes have been lost (colors added for emphasis) and the names have been merged:
ABBITT, CHANCE MABBOTT-HALL, RILEYABDALLA, JOSEPH MABEL, KEITH JACKERMAN...
Though maybe that's just poor output, and the names ARE being maintained, because my loop gets this error:
_"ABBITT, CHANCE M invalid name
So, problematic, because the loop is not running. However, at least it IS referencing the 1st name of the sequence I hope I'm saving (`"ABBITT, CHANCE M"').
So maybe the sequence is fine and I'm merely doing something wrong with the loop? I did try foreach lname of local "`names'" {} with no greater success.
Thanks!
Code:
levelsof names, local(names) di `names' foreach lname of local `names' { di "this loop is working" }
`"ABBITT, CHANCE M"' `"ABBOTT-HALL, RILEY"' `"ABDALLA, JOSEPH M"' `"ABEL, KEITH J"'...
After the second (di `names') I get this, where it looks like the double quotes have been lost (colors added for emphasis) and the names have been merged:
ABBITT, CHANCE MABBOTT-HALL, RILEYABDALLA, JOSEPH MABEL, KEITH JACKERMAN...
Though maybe that's just poor output, and the names ARE being maintained, because my loop gets this error:
_"ABBITT, CHANCE M invalid name
So, problematic, because the loop is not running. However, at least it IS referencing the 1st name of the sequence I hope I'm saving (`"ABBITT, CHANCE M"').
So maybe the sequence is fine and I'm merely doing something wrong with the loop? I did try foreach lname of local "`names'" {} with no greater success.
Thanks!
Comment