BookmarkSubscribeRSS Feed
art297
Opal | Level 21

They differ by the number of ampersands preceding the macro variable.

gfarkas
Calcite | Level 5

Right, but among the 6 in your post, #1 is identical to #4, and #2 is identical to #5, and #3 is identical to #6.

Linlin
Lapis Lazuli | Level 10

Agreed. they are the same to me too.

art297
Opal | Level 21

I have no idea, anymore, of what I had attempted to post back then.  It appears that the discussion was whether periods after a macro variable would cause the variable not to be resolved.  However, my example didn't correctly show that and, in fact, was confusing to say the least.

I just ran the following and they both appear to run correctly whether they do or don't include periods:

%let i=2;

%let name=acct_num;

/* All of the following work */

data x;

   acct_num2=12345;

   put &&name&&i;

run;

data x;

   acct_num2=12345;

   put &&name&&i.;

run;

data x;

   acct_num2=12345;

   put &&name.&&i;

run;

data x;

   acct_num2=12345;

   put &&name.&&i.;

run;

gfarkas
Calcite | Level 5

Am I missing something? Those two sets of 3 data steps look the same to me.

Ksharp
Super User

remove double quote.

put  &&name&i. ;

Peter_C
Rhodochrosite | Level 12

Hi Steve

among these responses, has someone suggested placing an = at the end?

Instead of

put "&&name&i.";

try

data ;

   acct_num=123456789 ;

   put  &&name&i=;

run ;

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
  • 21 replies
  • 2455 views
  • 1 like
  • 10 in conversation