BookmarkSubscribeRSS Feed
Quentin
Super User

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

--Q.

7 REPLIES 7
Quentin
Super User

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....

https://communities.sas.com/message/130850

Ksharp
Super User

SAS is not Object Oriented Programming language - like Java.

Quentin
Super User

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.

--Q.

Patrick
Opal | Level 21

Agree - seems bug-ish to me as well. Suggest you send this one to SAS TechSupport.

FriedEgg
SAS Employee

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.

Quentin
Super User

FriedEgg,

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.

--Q.

Ksharp
Super User

HeHe.

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).

Ksharp

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2336 views
  • 0 likes
  • 4 in conversation