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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 825 views
  • 0 likes
  • 1 in conversation