DATA Step, Macro, Functions and more

" Required operator not found in expression"

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

" Required operator not found in expression"

[ Edited ]
 
 

hi all.

Due to @Reeza, recomendation im opening this thread.

I am new at sas and having some issues with %IF %ELSE conditions, I am trying to write a macro to execute some code on the when  the last  date, on a data set, is from "today - 1"  but whe i run the  macro it keep giving the error "Required operator not found in expression" 

 

/* +++++++++ Variables*/
rsubmit;
proc sql;
select max(offer_Date) into :valDateSales
from qwer ;
quit;
proc sql;
select max(offer_Date) into :valDateOffers
from asdf;
quit;
%let maxDateSales= %sysfunc(substrn(&valDateSales.,1,9));
%let maxDateOffers= %sysfunc(substrn(&valDateOffers.,1,9));
endrsubmit;
/* +++++++++ MACRO*/

 %macro Continuity(MaxDateSales, MaxDateOffers);
     %Let yesterday = %eval(%sysfunc(today())-1);
        %if ("&MaxDateSales."d eq "&yesterday."d)%then %do;
              %if ("&MaxDateOffers."d eq "&yesterday."d))  %then %do;
                  %export_to_Drive(ds=workunx.X, outf_name=ASDF..csv)
                  %export_to_Drive(ds=workunx.Y, outf_name=qwer.csv)
                  %export_to_ftp(dsn=workunx.x,outfile_name=asdf..csv)); 
                  %export_to_ftp(dsn=workunx.Y ,outfile_name=qwer..csv));
                  %successMailing();
                  %put "succes statement";
              %end;
              %else %do;
                  %failMailing();
              %end
        %else %do;
              %failMailing();
              %put "fail statement";
        %end;
  %mend;
/*++++++LOG

693  %Continuity(MaxDateSales=&MaxDateSales., MaxDateOffers=&MaxDateOffers.);
MLOGIC(CONTINUITY):  Beginning execution.
SYMBOLGEN:  Macro variable MAXDATESALES resolves to 20806
SYMBOLGEN:  Macro variable MAXDATEOFFERS resolves to 20806
MLOGIC(CONTINUITY):  Parameter MAXDATESALES has value 20806
MLOGIC(CONTINUITY):  Parameter MAXDATEOFFERS has value 20806
MLOGIC(CONTINUITY):  %LET (variable name is YESTERDAY)
SYMBOLGEN:  Macro variable MAXDATESALES resolves to 20806
SYMBOLGEN:  Macro variable YESTERDAY resolves to 20806
MLOGIC(CONTINUITY):  %IF condition ("&MaxDateSales."d eq "&yesterday."d) is TRUE
SYMBOLGEN:  Macro variable MAXDATEOFFERS resolves to 20806
SYMBOLGEN:  Macro variable YESTERDAY resolves to 20806
ERROR: Required operator not found in expression: ("&MaxDateOffers."d eq "&yesterday."d))
ERROR: The macro CONTINUITY will stop executing.
MLOGIC(CONTINUITY):  Ending execution.
NOTE: Remote submit to A complete.
 

well as i have said, i am new at SAS so please, any help will be appreciated.


Accepted Solutions
Solution
‎12-20-2016 09:45 AM
Super User
Posts: 5,071

Re: " Required operator not found in expression"

[ Edited ]

It can't hurt to remove the d (as Reeza suggested).  But the likely cause of the problem is that you have an extra right-hand parenthesis on that same line of code. 

 

(Also note a couple of instances of an extra right-hand parenthesis on two of the later lines that call the macro.)

 

View solution in original post


All Replies
Super User
Posts: 17,743

Re: " Required operator not found in expression"

Your macro is nested and you're calling several different macros. I think the error is in one of those macros, not the one shown. 

Is this your code or are you running someone else's and trying to debug?

 

PS please try and format the code, I know the forum does change it sometimes, but the current layout is difficult to read.

 

Occasional Contributor
Posts: 5

Re: " Required operator not found in expression"

1.- it is my code, but is an extention for an older code of some one else.

2.- i have tried to comment all the macros that this code is calling, but the error stay there.

3.- i have tried to format de posted code, but the forum change it a lot =(

 

thaks for the  quick reply

Super User
Posts: 17,743

Re: " Required operator not found in expression"

Try fixing this issue:

SYMBOLGEN:  Macro variable MAXDATESALES resolves to 20806
SYMBOLGEN:  Macro variable MAXDATEOFFERS resolves to 20806

 

Your code:

 

 %if ("&MaxDateOffers."d eq "&yesterday."d))  %then %do;

 

Replacing the values generates invalid SAS code:

 

 %if ("20806"d eq "20806"d))  %then %do;

 

Your dates are not formatted correctly. So either format them as Date9 or remove the D from the comparison. 

It should look like:

 

 %if ("18Dec2016"d eq "18Dec2016"d))  %then %do;

 

Trusted Advisor
Posts: 1,353

Re: " Required operator not found in expression"

As %IF compares character strings ther is no need - 

    neither to use "&var"d  nor change into "ddmmmyy"d

   but just to use 

%if &MAXDATESALES = &MAXDATEOFFERS

 

 

Occasional Contributor
Posts: 5

Re: " Required operator not found in expression"

thank you it help, not solve it but help a lot.
Solution
‎12-20-2016 09:45 AM
Super User
Posts: 5,071

Re: " Required operator not found in expression"

[ Edited ]

It can't hurt to remove the d (as Reeza suggested).  But the likely cause of the problem is that you have an extra right-hand parenthesis on that same line of code. 

 

(Also note a couple of instances of an extra right-hand parenthesis on two of the later lines that call the macro.)

 

Occasional Contributor
Posts: 5

Re: " Required operator not found in expression"

thank you for notice it!
☑ This topic is SOLVED.

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

Discussion stats
  • 7 replies
  • 1806 views
  • 4 likes
  • 4 in conversation