User981636
User981636

Reputation: 3621

SAS SQL using a where condition with macro variable

I have a proc sql procedure in SAS where my where clause should be dynamic (the set of ID numbers will be updated in the future).

I could do something as follows for a unique character condition:

%let value1=A ;
proc sql  ;
select * from sashelp.class
where upcase(name) contains symget('value1');
;
quit;

However, how could do the same to check several numbers? How could I make the following work?

%let value2= (11,12,13);
    proc sql  ;
    select * from sashelp.class
    where age not in symget('value2');
    ;
    quit;

Upvotes: 1

Views: 861

Answers (1)

data _null_
data _null_

Reputation: 9109

Resolve the value of VALUE2 before execution.

%let value2= (11,12,13);
proc sql  ;
   select * from sashelp.class
      where age not in &value2
      ;
   quit;

Upvotes: 1

Related Questions