Skip to content
Advertisement

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;

Advertisement

Answer

Resolve the value of VALUE2 before execution.

%let value2= (11,12,13);
proc sql  ;
   select * from sashelp.class
      where age not in &value2
      ;
   quit;
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement