Created
June 25, 2021 17:44
-
-
Save statgeek/dd57887f1d34f3dc6476471d9ac035ed to your computer and use it in GitHub Desktop.
SAS - dynamically generate a list for filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
One common issue with using SQL pass through is that you sometimes want to use data that is on your SAS server. Rather than pass this information to the server, to be used in a subquery or join, you can pass the values directly by dynamically generating the code and lookup lists | |
*/ | |
%let age = 14; | |
data test; | |
set sashelp.class end = eof;; | |
where age = &age.; | |
if _n_ =1 then do; | |
call execute('proc sql; select * from sashelp.class where name in ('); | |
end; | |
if not eof then do; | |
call execute(quote(name)); | |
call execute(","); | |
end; | |
if eof then do; | |
call execute(quote(name)); | |
call execute("); quit;"); | |
end; | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment