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

% macro test;

  data _null_;

    call symputx('name', 'Philip')

run;

%mend test;

%test

%put _global_;

I thought call symputx creates local macro variable in the macro definition.  After checking name is global macro variable.  I appreciate clarification in this.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  There is a search path that is used to determine whether you create your macro variable in a GLOBAL or LOCAL table. You need to read about it in the documentation. When inside a macro that does not otherwise need/create a local table, your macro variable will be written to the global table. The beauty of CALL SYMPUTX is that you can CONTROL where the macro variable will be written. See the attached screen shot. The 3rd argument to the call routine allows you to specify a string that is the location: "L" for local or "G" for global or Your macro definition does not use or create a LOCAL symbol table. 'F' means write it in the most local table IF the macro variable is found. Look at the attached screen shot for an example of using 'L' and 'G' -- that's where I would recommend starting.

cynthia


force_write_local_or_global.png

View solution in original post

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:

  There is a search path that is used to determine whether you create your macro variable in a GLOBAL or LOCAL table. You need to read about it in the documentation. When inside a macro that does not otherwise need/create a local table, your macro variable will be written to the global table. The beauty of CALL SYMPUTX is that you can CONTROL where the macro variable will be written. See the attached screen shot. The 3rd argument to the call routine allows you to specify a string that is the location: "L" for local or "G" for global or Your macro definition does not use or create a LOCAL symbol table. 'F' means write it in the most local table IF the macro variable is found. Look at the attached screen shot for an example of using 'L' and 'G' -- that's where I would recommend starting.

cynthia


force_write_local_or_global.png

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
  • 1 reply
  • 18235 views
  • 5 likes
  • 2 in conversation