I am trying to resolve a macro variable from within a macro call and it will not resolve and I don't know why. Below is my code and the log.
Any assistance will be greatly appreciated.
data _NULL_;
if 0 then set final nobs=n;
call symput('nrows',trim(left(put(n,8.))));
stop;
run;
%put nobs=&nrows;
%global obscount fini_total;
proc sql;
select count(*) into: fini_total
from final
;
quit;
proc freq data= final;
tables Message_Number /
list missing out=frequency;
run;
DATA freq_total;
SET frequency;
SAMPSIZE=(PERCENT*&fini_total.)/100;
_NSIZE_=ROUND(SAMPSIZE,1);
IF _NSIZE_ gt 0;
RUN;
proc sql noprint;
select count(*)
into :obscount
from freq_total;
quit;
%macro recs();
/******* RUN THIS If FINAL has RECORDS ********/
data _null_;
if &nofac < &obscount then call symput ('N',&obscount);
else if &nofac > &fini_total then call symput ('N',&fini_total);
else call symput ('N',&nofac);
run;
proc surveyselect data=final
n=&&N out=ALERT_LIST_Sample;
strata 'Message_Number'n / alloc=prop;
run;
%PUT N=&&N;
%mend recs;
%macro norecs();
/******* RUN THIS If NO RECORDS - TO PRODUCE A 0 RECORD REPORT ********/
data ALERT_LIST_SAMPLE;
set final;
run;
%mend norecs;
data _null_;
if &nrows. = 0 then call execute('%norecs');
else call execute('%recs');
run;
296
297 %macro recs();
298 /******* RUN THIS If FINAL has RECORDS ********/
299 data _null_;
300 if &nofac < &obscount then call symput ('N',&obscount);
301 else if &nofac > &fini_total then call symput ('N',&fini_total);
302 else call symput ('N',&nofac);
303 run;
304
305 proc surveyselect data=final
306 n=&&N out=ALERT_LIST_Sample;
307 strata 'Message_Number'n / alloc=prop;
308 run;
309
310 %PUT N=&&N;
311
312 %mend recs;
313
314 %macro norecs();
315 /******* RUN THIS If NO RECORDS - TO PRODUCE A 0 RECORD REPORT ********/
316
317 data ALERT_LIST_SAMPLE;
318 set final;
319 run;
320
321 %mend norecs;
322
323 data _null_;
324 if &nrows. = 0 then call execute('%norecs');
325 else call execute('%recs');
326 run;
WARNING: Apparent symbolic reference N not resolved.
WARNING: Apparent symbolic reference N not resolved.
11 The SAS System 07:19 Thursday, May 31, 2018
N=&N
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 250.65k
OS Memory 19116.00k
Timestamp 05/31/2018 08:05:02 AM
Step Count 24 Switch Count 40
Page Faults 0
Page Reclaims 17
Page Swaps 0
Voluntary Context Switches 106
Involuntary Context Switches 2
Block Input Operations 16
Block Output Operations 0
NOTE: CALL EXECUTE generated line.
1 + data _null_; if 9 < 4 then call symput ('N', 4); else if 9 > 26 then call
symput ('N', 26); else call symput ('N', 9); run;
... View more