LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 11 Dec 2008 12:41:54 -0500
Reply-To:     Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject:      Re: Macro
Comments: To: ganeshkumar.mohanan@GMAIL.COM

On Thu, 11 Dec 2008 08:57:10 -0800, GAN <ganeshkumar.mohanan@GMAIL.COM> wrote:

>What is the difference beteen &a and &&a .?how sas its diffrentiate ?

hi, Ganesh,

Stand alone, they resolve to the same thing. If a part of something larger, then it may not. See an example below.

%*-- stand alone, &x and &&x are the same. --*; %symdel a; %let a = x; %*-- as it is &a and &&a are the same --*; %put NOTE: %str(&)a=&a %nrstr(&&)a=&&a;

%*-- as a part of something, they may make differences --*; %symdel a b xb ay; %let a = x; %let b = y; %let xb = xb; %let ay = ay; %put NOTE: %str(&)a%str(&)b=&a&b %nrstr(&&)a%str(&)b=&&a&b;

%*-- on log NOTE: &a=x &&a=x NOTE: &a&b=xy &&a&b=ay --*;

The detailed explanation is a bit more complicated. Given "&&a", Macro processor takes "&&" and returns "&" first. Then it takes "a" and returns "a". Thus "&&a" becomes "&a". But sas does not stop here! It then remembers that it had "&" before and goes back to "&" and "scans forward" and tries to resolve "&a". And this is not the end of the story, either. What happens there exists no macro variable a? What if this is also a part of a larger macro expression? And so on... :-)

This is, in my opinion, not a clean hack. I believe that it is a design mistake, which "proudly" brought us some ugly compound references in macro like: &&var&n, &&&&div&&dept&n, &&&var, or &&&&&&&&something

If you are interested in this topic, then this thread may help: http://tinyurl.com/6ggpjt or http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0804B&L=sas-l&P=R17764&D=1&H=0&O=D&T=1

See also Don's best explanation/defense on behalf of sas's: http://tinyurl.com/6cq4gf or http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0804B&L=sas-l&D=1&H=0&O=D&T=1&P=28908

cheers, chang


Back to: Top of message | Previous page | Main SAS-L page