04-11-2012 11:18 AM
I do see couple of examples that macro variables don't have ampersand in front of them when they are referenced.
Can you tell me under what scenario, this rule applies?
04-11-2012 11:30 AM
I would be interested in seeing where you have found that. Any macro variable I've run across is always preceded with the ampersant. Is it possibly you are confusing a datastep automatic variable such as _n_ or _infile_ with a macro variable?
04-11-2012 11:41 AM
There are just a handful of cases. Here are the ones I can think of off the top of my head.
In a DATA step, CALL SYMPUT and SYMGET both expect to see the name of a macro variable. So the ampersand should be omitted (although since it's in a DATA step, quotes would distinguish between a DATA step variable vs. a text string). For example, both of these create a macro variable &SALES:
call symput('sales', 'Friday');
call symput(varname, 'Friday');
Other than that, the only case I can think of is the %superq function. It also expects the name of a macro variable. For example:
call symput('measure', 'S&P 500 Index');
%let measure = superq(measure);
This would quote the &P, so that resolving &measure does not trigger a search for the macro variable &P.