How can i use macro with if, else, end statement, if i want to just start sql if the condition is true.
I wanna just use if statement, so if today()= date column from my table, and if this is true, then run this sql:
create table work.filtered_data AS
select *
from xxx
data _null_;
set have;
if date=today() then call symputx('start',1);
else call symputx('start',0);
run;
%if &start=1 %then %do;
proc sql;
...
quit;
%end;
Works in SAS 9.4M5 and later.
So you have a date variable in a dataset. Will this variable contain only a single distinct value in all observations, or different dates?
just one, it is just one exact date in every month (but not same every month) when i need to start macro. But it is just one value in dataset everytime.
data _null_;
set have;
if date=today() then call symputx('start',1);
else call symputx('start',0);
run;
%if &start=1 %then %do;
proc sql;
...
quit;
%end;
Works in SAS 9.4M5 and later.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.