BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi. Is there any way to declare global macro-variables with dynamic varaible-names?
Or rather; i tried to write a %global statement like

%global &mvar

in a do-loop. The macro-variable mvar contains the actual variable-name for the global statement; but i woudln't be solved.
If i write %global "&mvar" it would be solved as %global "mvarcontent", but %global didn't work with qutotet variable-names. Message was edited by: idefix
4 REPLIES 4
deleted_user
Not applicable
I wrote a macro including a data-step which creates a lot of macro-variables with call symput function.
Later i need that macro-variables in another macro; but they are not available (local in the other macro).
deleted_user
Not applicable
then use CALL SYMPUTX() with the G parameter

or create them local to the environment under which they are filled and used alternatives to Global macro variables exist


Message was edited by: Peter_c
deleted_user
Not applicable
SYMPUTX with the G parameter also creates non global variables within a macro.

But ... it think they are not really local.

If i put them with %put _users_ into the log i get a list like this:

TEST_MACRO mvar_1
GLOBAL _SASSPLEVEL SAS 9.1.3 Service Pack 4
GLOBAL _EGUSERNAME 
GLOBAL _EGSERVERNAME SASReporting

The variable-type is the macro-name, not global or local.
Might that be the problem?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1064 views
  • 0 likes
  • 1 in conversation