BookmarkSubscribeRSS Feed
ScottBass
Rhodochrosite | Level 12

Hi,

put me on to this new feature in SAS 9.3 via a LinkedIn post.

From the 9.3 SAS doc (see Tip for the %PUT statement):

%let x=1;

%put &=x;

However, can anyone (a little birdie perhaps?) say why this doesn't work?

%let y1=2;

%let i=1;

%put Y&i=&&y&i;  * works ;

%put &=y1;  * works ;

%put &=y&i;  * does not work ;

or my more realistic example (from a macro I'm writing):

%let z1=A;

%let z2=B;

%let z3=C;

%macro test;

  %do i=1 %to 3;

    %put Z&i=&&z&i;  * works ;

    %put &=z&i;  * does not work ;

  %end;

%mend;

%test;

Otherwise, consider this a minor bug report and/or enhancement request.


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
2 REPLIES 2
JerryLeBreton
Pyrite | Level 9

I think its a "feature".

The doco says: "If you place an equal sign between the ampersand and the macro variable name of a ** direct ** macro variable reference, the macro variable's name displays in the log along with the macro variable's value.

It would be good to be able to an indirect reference though.

MichelleHomes
Meteorite | Level 14

Hi Scott & Jerry,

Yes it does appear to be a feature for only "direct" macros. Thought I'd reference the documentation page as well (look for the Tip), http://support.sas.com/documentation/cdl/en/mcrolref/64754/HTML/default/viewer.htm#n189qvy83pmkt6n1b...

Cheers,

Michelle

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com

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!

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
  • 2 replies
  • 2628 views
  • 0 likes
  • 3 in conversation