The IN operator in SAS wants a list of VALUES, not function calls.
The IN operator in SQL also allows a subquery, hence the reference to a missing SELECT.
Examples:
71 proc sql;
72 select * from sashelp.class
73 where age in (13)
74 ;
75 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
76 proc sql;
77 select * from sashelp.class
78 where age in (130/10)
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, a missing value, ), ',', -,
:.
ERROR 200-322: The symbol is not recognized and will be ignored.
79 ;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
80 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
81 proc sql;
82 select * from sashelp.class
83 where age in (select age from sashelp.class where age=130/10)
84 ;
85 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
Since your functions are not referencing anything that varies you could use the macro language to generate the date constants.
For example by using %SYSFUNC() to call the SAS functions.
where datepart(a.ma_date) in
(%sysfunc(intnx(year,%sysfunc(today()),-1,e))
,%sysfunc(intnx(year,%sysfunc(today()),-2,e))
,%sysfunc(intnx(year,%sysfunc(today()),-3,e))
)
Or just put the dates needed into a macro variable.
data _null_;
length datelist $100;
do offset=1 to 3 ;
datelist=catx(' ',datelist,intnx('year',today(),-offset,'e'));
end;
call symputx('datelist',datelist);
run;
%put &=datelist;
...
where datepart(a.ma_date) in (&datelist)
...
... View more