06-28-2012 11:04 AM
This is mostly a teaser question. Wondering if anyone has a good theory as to how an environment like below could be created, where SAS reports there are 2 global macro variables with the same name and different values. I'm working on a (much longer) post where I will show how I think it's happening, and will ask more questions there. Will add a link to that thread in the responses, but was curious as to whether folks had seen this sort of oddity before.
MPRINT(SHOW): data _null_; MPRINT(SHOW): set sashelp.vmacro; MPRINT(SHOW): where name='G'; MPRINT(SHOW): put (name scope offset value)(=); MPRINT(SHOW): run; name=G scope=GLOBAL offset=0 value='TEST' name=G scope=GLOBAL offset=0 value=GLOBAL
06-28-2012 03:24 PM
Maybe I failed to pique much interest... Here is a link to the long post where I decribe how I managed to create two global macro variables with the same name, and ask for help in understanding how it happened....
06-29-2012 08:18 AM
Agreed Ksharp, but not sure I see your point.
Even though SAS is not object-oriented there are still "rules" in SAS's design about what should be unique. So you can't have two datasets in the same library with the same name, can't have two variables in the same dataset with the same name, can't have two different title1 lines defined at the same time. In the same way, I don't see how it can make sense for there to be two global macro variables with the same name at the same time. Seems bug-ish to me.
06-29-2012 01:40 PM
I think you brought this up on SAS-L also. It is an interesting situation. Seems to only occur in 9.3 and not in 9.2. So, it certainly seems as though it is a bug with the scope of programs executed in this unique fashion.
06-29-2012 10:25 PM
Yes, it's the same issue I brought up on SAS-L. Just thought I would put it out here as well to collect as much feedback / suggestions as I could, before going to tech support with it. And was surprised by Ksharp's response.
07-01-2012 10:44 PM
I agree with you that you cann't have two variables with the same name wthin the same dataset. Maybe you should contact with Technical Support.
Nowadays, I am learning JAVA (JavaEE) , So it is not problem for OOP. An object ( a macro variable) can have two fields ( values).