Is it possible to pass in a Where? like...
%macro test(where); proc sql; create table temp as select field1, field2 from tableA where &where; quit; %mend test; %test("ap_period='1234'")
Yes, but slightly easier if you use WHERE =
e.g
%macro test(where=);
proc sql;
create table temp as
select name, age from sashelp.class where &where;
quit;
%mend test;
%test(where= age=15);
@StaticFX wrote:
Is it possible to pass in a Where? like...
%macro test(where); proc sql; create table temp as select field1, field2 from tableA where &where; quit; %mend test; %test("ap_period='1234'")
that simple?
lol guess i shouldve tried it first! Thanks! testing now
Yes, but slightly easier if you use WHERE =
e.g
%macro test(where=);
proc sql;
create table temp as
select name, age from sashelp.class where &where;
quit;
%mend test;
%test(where= age=15);
@StaticFX wrote:
Is it possible to pass in a Where? like...
%macro test(where); proc sql; create table temp as select field1, field2 from tableA where &where; quit; %mend test; %test("ap_period='1234'")
Bingo! the first way didnt quite work.. this works perfectly thanks!!
Just wrap your condition inside of parentheses instead of quotes.
%test((ap_period='1234'))
Also note that you can use named parameters in the macro call, even if the macro has it defined as a positional argument.
You just can't try to pass a value by position when the parameter is defined as named in the %macro statement.
%test(where=ap_period='1234')
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.