DATA Step, Macro, Functions and more

macro variables not getting resolved

Accepted Solution Solved
Reply
Contributor
Posts: 36
Accepted Solution

macro variables not getting resolved

Hi,

I have the following code -

%macro wkrpt;
%do i=1 %to 2;
rsubmit;
proc sql inobs=10000;
create table report_2_pt&i as
(
   select location_id as LocationId,

   
       sum( case when week = %eval(&i.) and transaction_type_id = 905 then 1 else 0 end)
                                                                  as StarterKitsSold_&&&wkcnt&i.

from final_trans_Set

group by x

order by x

);

quit ;

endrsubmit;

%end;

%mend wkrpt;

%wkrpt

It is unable resolve &i. I get the following message in the log -

WARNING: Apparent symbolic reference I not resolved.

Also  &&&wkcnt&i. is not getting resolved, because I is not resolved.

When I do put statement, following is the dump from log -

95   %put &wkcnt1;

SYMBOLGEN:  Macro variable WKCNT1 resolves to 01/03/2015

01/03/2015

Can you kindly advice?


Accepted Solutions
Solution
‎03-02-2015 03:02 PM
Trusted Advisor
Posts: 1,300

Re: macro variables not getting resolved

use %nrstr around any macro variables you want to reference withing the remote session.

%macro wkrpt;

%do i=1 %to 2;

%syslput i=&i. /remote=remhost;

rsubmit;

proc sql inobs=10000;

create table %nrstr(report_2_pt&i.) as

View solution in original post


All Replies
Trusted Advisor
Posts: 1,300

Re: macro variables not getting resolved

Your macro variable is not local to the remote submission.  Use %syslput.

http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001221974.htm

Contributor
Posts: 36

Re: macro variables not getting resolved

Thanks a lot @FriedEgg. Do you have any idea how the syntax would look like ?

I tried putting the %syslput statement after the %do loop, assuming it will put all variables including i at remote host.

But in the log it is still not recognizing I. Do you have any sample code for such looping situation ?

-------------LOG-------------------------

114  %macro wkrpt;

116  %do i=1 %to 2;

117  %syslput _user_/ remote = remhost;

118  rsubmit;

NOTE: Remote submit to REMHOST commencing.

166  proc sql inobs=10000;

167  create table report_2_pt&i as

                             -

                             22

WARNING: Apparent symbolic reference I not resolved.

167  create table report_2_pt&i as

Solution
‎03-02-2015 03:02 PM
Trusted Advisor
Posts: 1,300

Re: macro variables not getting resolved

use %nrstr around any macro variables you want to reference withing the remote session.

%macro wkrpt;

%do i=1 %to 2;

%syslput i=&i. /remote=remhost;

rsubmit;

proc sql inobs=10000;

create table %nrstr(report_2_pt&i.) as

Contributor
Posts: 36

Re: macro variables not getting resolved

Thanks a lot!!

Respected Advisor
Posts: 3,124

Re: macro variables not getting resolved

Also, &&&wkcnt&i seems not to be your intent, you have one more &, when resolving, when first scan, &&->& ,  &wkcnt and &i will be required to be resolved at the same time. so shouldn't it be &&wkcnt&i?

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 337 views
  • 6 likes
  • 3 in conversation