BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GabrielGajardo
Fluorite | Level 6
 
 

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

7 REPLIES 7
Reeza
Super User

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.

 

GabrielGajardo
Fluorite | Level 6

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

Reeza
Super User

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;

 

Shmuel
Garnet | Level 18

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

 

 

GabrielGajardo
Fluorite | Level 6
thank you it help, not solve it but help a lot.
Astounding
PROC Star

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.)

 

GabrielGajardo
Fluorite | Level 6
thank you for notice it!

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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