Hi:
There is a difference between storing the macro PROGRAM and referencing macro VARIABLES. The macro PROGRAM can be created and used within a session (where it would live in the WORK.SASMACR catalog) or it can be stored and referenced from an AUTOCALL library or it can be stored and referenced from a stored, compiled macro location.
Macro VARIABLES, on the other hand, are somewhat ephemeral. They are not "stored" from session to session. They either live, within one session, in a GLOBAL symbol table or a LOCAL symbol table. However, if you store your macro PROGRAM, it is the creation method, the creation logic which you are storing -- NOT the macro VARIABLES themselves. Macro VARIABLES can be created in a variety of different ways, but they only "live" in memory for the duration of your session. One way to create macro variables is with %LET, another way is with CALL SYMPUT. Either of those methods work outside and inside a macro PROGRAM. So you have several different combinations of creation possibilities.
It seems like you are confusing the storage of macro PROGRAMS with how to reference macro VARIABLES. Every time you run your %FREQ macro PROGRAM, it will, indeed, create 2 macro VARIABLES called &NAME1 and &NAME2 -- they will however, be LOCAL in scope -- that is, they will only live in the memory of the LOCAL symbol table for macro variables unless you explicitly make them GLOBAL. Consider this program:
[pre]
%let name1 = Mary;
%let name2 = William;
ods listing;
title "List for: &name1, &name2";
proc print data=sashelp.class;
where name in ("&name1", "&name2");
run;
[/pre]
You do not need a macro PROGRAM to create or use two macro variables. A good rule of thumb when designing a macro PROGRAM or process is to start with a WORKING program. In your case, you should start from the program that gives you the desired output. For example, to generate the above program, I started with this:
[pre]
ods listing;
title "List for selected students";
proc print data=sashelp.class;
where name in ("Mary", "William");
run;
[/pre]
Then I figure out where I could use my macro VARIABLES, decided on the names of those macro VARIABLES and then tested them out in the program by assigning values to &NAME1 and &NAME2 and then using those macro VARIABLES to see whether they'd work in the program as it was written. As you can see, I decided to change the title to show the names that I was selecting.
Some information on the scope of macro VARIABLES can be found here:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293860.htm
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001072159.htm
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001072103.htm
A good introduction to the difference between macro VARIABLES and a macro PROGRAM is here:
Doc on Using macro VARIABLES:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002047074.htm
Intro to Macro Facility (user group paper):
http://www2.sas.com/proceedings/sugi28/056-28.pdf
cynthia