BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

Hello,

 

Is it possible to make a call symputx in a macro function without using a data step as below?

 

%macro test;

%global Gflag;

 

Data _null_;

call symputx('Gflag',0);

 

stop;

run;

%mend test;

 

%test;

%put &Gflag;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

As far as I know, call symputx can only be run in data step. 

 

Perhaps if you could explain what you are doing and why you think you need it outside a data step, we could come up with a simple solution.

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

As far as I know, call symputx can only be run in data step. 

 

Perhaps if you could explain what you are doing and why you think you need it outside a data step, we could come up with a simple solution.

--
Paige Miller
alepage
Barite | Level 11

I just need to do a call symputx in a macro function and I wonder if there is another way to make that call outside of a data step to avoid those extra lines of code.

 

Data _NULL_;

...

Stop;

run;

just a curiosity!

PaigeMiller
Diamond | Level 26

There are other way to assign values to macro variables, if you are outside a data step. The two that come to mind are PROC SQL and %LET. Wouldn't one of those work for you?

--
Paige Miller
RW9
Diamond | Level 26 RW9
Diamond | Level 26

If you need global scope then:

call symput('mvar',0,'g');

The g means set as global.  However that being said its really not a good idea to be setting gloabl macro variables inside a macro - scoping, encapsulation etc.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1465 views
  • 1 like
  • 3 in conversation