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

hi All,

I have created macro variables

%let B1=123;
%let B2=231;

%let B3=8;
Trying to call these inside a do loop.

data one;
array var[3] first second third ;
do j = 1 to 3;
var[j]= &Bj.;
end;
run;

The above code does not work. Please suggest

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

Macro variables are normally resolved during datastep compilation, so in order to get at them dynamically in a datastep, you will have to use SYMGET:

data one;
  array var[3] 8 first second third ;
  do j = 1 to 3;
    var[j]= input(symget(cats('B',j)),best32.);
    end;
run;

View solution in original post

2 REPLIES 2
s_lassen
Meteorite | Level 14

Macro variables are normally resolved during datastep compilation, so in order to get at them dynamically in a datastep, you will have to use SYMGET:

data one;
  array var[3] 8 first second third ;
  do j = 1 to 3;
    var[j]= input(symget(cats('B',j)),best32.);
    end;
run;
deepakg77717
Calcite | Level 5
Thank you for the reply..It works fine now...

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
  • 576 views
  • 1 like
  • 2 in conversation