Search code examples
sqlsassas-macro

Is there a function to check if an element exist in a macro variable?


i have a table Z with two columns a(string) and b(integer) the elements in a change for every session so i crate a macro variable to each session !

%Let Fe='abc','def','mno';
%let mylist = &session_1. &session_2. &session_3.;

%macro print_session_3(mylist) / minoperator ; 
%let session_3=session_3;
    %IF  &session_3. in &mylist. %THEN %DO;
        proc sql;
            create table DATA.session_3 as
        select  a , b
        from source.Z
            where a in &Fe.
        and b>4
    ;quit;
    %end; 
%mend;
%print_session_3(&mylist);

I hope that's clear enough for u , The error is :"Expecting a )"


Solution

  • It means that you missed a ).

    You should use in operator with list of values in () in where statement.

    It will look like:

    where a in (&Fe.)