Apparent symbolic reference not resolved.

Reply
Contributor
Posts: 44

Apparent symbolic reference not resolved.

I have the below code which selects the latest dataset name, however I am getting an error message :, please advise any ideas..

%macro date_loop(start,end);

/*converts the dates to SAS dates*/
%let start=%sysfunc(inputn(&start,anydtdte9.));
%let end=%sysfunc(inputn(&end,anydtdte9.));
/*determines the number of months between the two dates*/
%let dif=%sysfunc(intck(day,&start,&end));
%do i=0 %to &dif;
/*advances the date i months from the start date and applys the DATE9. format*/
                    %let dCallDate = %sysfunc(intnx(day,&start,&i,b));
  %let date=%sysfunc(putn(&dCallDate,date9.));
  %put &date;

                    /* check the latest next event report date */
                    %let ActiveReport = ;
                    %do j = 0 %to 4;
                                        %let dActiveDate = %sysfunc(intnx(day, &dCallDate, -&j));
                                        %let ActiveDate = %sysfunc(putn(&dActiveDate -1, Date7.));
                                        %let DatasetName = ACTIVE.D&ActiveDate;

                                        %if %sysfunc(exist(&DatasetName)) %then
                                                            %do;
                                                                                %let ActiveReport = &DatasetName;
                                                                                %let j = 5;
                                                            %end;

                                       
                    %end;
%end;
                    %put Found Active report for &date at &ActiveReport;
                   
                    %mend;
%date_loop(19Aug2014,24Aug2014);
                  data ACT;
set &ActiveReport;
XX = substr(CUR_STATE,2,2);
YY = substr(LST_STATE,2,2);
run;

WARNING: Apparent symbolic reference ACTIVEREPORT not resolved.
ERROR: File WORK.ACTIVEREPORT.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, END, INDSNAME, KEY, KEYS, NOBS, OPEN,
              POINT, _DATA_, _LAST_, _NULL_. 

ERROR 200-322: The symbol is not recognized and will be ignored.

Super User
Posts: 11,343

Re: Apparent symbolic reference not resolved.

Looks like a scope issue since it appears you are using &Activereport outside the macro creating it. Add

%global ActiveReport; to the code inside the macro so it is available outside.

Super Contributor
Posts: 308

Re: Apparent symbolic reference not resolved.

Or you can move the datastep inside the macro definition.

Frequent Contributor
Posts: 89

Re: Apparent symbolic reference not resolved.

indeed, the macro is NOT global and not available outside the macro.

use %GLOBAL statement!!

date_loop(start,end);

     %GLOBAL activereport ;

     . . . .

Ask a Question
Discussion stats
  • 3 replies
  • 535 views
  • 6 likes
  • 4 in conversation