05-21-2018 11:56 AM
Dear SAS community,
I had a Macro to cut every 4000 records into a new macro which later I can use them as filters in my proc sql query, my macro is as following:
%do i=1 %to &test;
select distinct "'"||ID||"'" into :group&i separated by ','
from BPLCheck.padrug (firstobs=%eval(4000*(&i-1)+1) obs=%eval(4000*&i) )
However, while I call the &group1 and &group 2 within my proc sql query in the where statement,
where (id in (&group1) or (&group2))
SAS can not recognize those two macros. What did I do wrong? How can I make this work.
Any help is greatly appreciated.
05-21-2018 12:03 PM
When SQL creates macro variables, it creates them in the local symbol table. But you need them to be global, so they will exist after %TEST finishes executing. To do that, add this statement after %DO but before PROC SQL:
Also note, the later WHERE statement is abbreviated. In practice you would be using:
where (id in (&group1) or id in (&group2));