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?
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
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
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
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
Thanks a lot!!
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?
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.
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.