To expand on Maarten's comment:
_local_ means precisely that. A local macro is visible only within its
locale -- not a Stata term, but one that can be borrowed from other
programming languages.
That means, in Stata terms,
1. Within an interactive session.
2. Within a program (explicitly so defined, i.e. using the -program-
command).
3. Within a do file, including within code run from the do-file editor.
"Within" means exactly what says. A local is not visible beyond such
locales.
This is really a major feature, not a limitation. If it were not so, and
"local" were just a name without the meaning implied, you would need to
worry that your locals could mess up other programs' locals, and vice
versa. As most Stata commands, including commands that are run by other
commands that you don't even know about, are in Stata's own language and
make some use of locals, you would probably end up too paranoid to use
any locals at all.
But it is so.
But you do have situations where you want your locals, or more precisely
their contents, to be visible outside a locale. So, what you do?
1. You can use globals for this purpose. Globals are often disapproved
of, even deprecated, to the extent that some users get the impression
that they are part of Stata's language, but should not be used. That
negativity is often carried a bit too far. Globals have their roles, and
this is one such role.
2. Better style in many ways, however, is to pass locals, or again more
precisely their contents, to your do files as arguments, or to start
writing your own programs. This is all covered well in [U]. Despite a
background in other programming languages, my first phase as a Stata
user was dominated by writing do files that took arguments. It's a very
good stepping stone to full-blown programming and that day when you
start trying to get to grips with -syntax-.