Hello folks!
A small question concerning the automation of macro's-
SO let's say I have %a & %b that I want to run under certain circumstances-
Lets say that if the day of the month is between 1 and 7 I want %a to run otherwise I want %b to run;
Thank you all again.
Lawrence
One way would be with a third macro. Something like the following should work:
%macro driver;
%if %sysfunc(day(%sysfunc(today()))) le 7 %then %do;
%a
%end;
%else %do;
%b
%end;
%mend driver;
%driver
One way would be with a third macro. Something like the following should work:
%macro driver;
%if %sysfunc(day(%sysfunc(today()))) le 7 %then %do;
%a
%end;
%else %do;
%b
%end;
%mend driver;
%driver
Thanks Art.
That helps. I was close but was missing an element or two.
Art,
Question-
If i want to simply end the program if it does not fall on a specific day, how does that go?
Thanks.
Lawrence
I think that would depend on precisely what you want to happen next. If you just want to stop a currently running data step you could always just route the code to a stop statement. e.g.,
Hi Art-
Thanks for the link, however, It is part of a larger macro so that I just want to "kill" the program if it doesn't fall on a specific day, plus actually I have a few programs bundled as well so I don't want to recode everything again. Is this feasible?
Thanks again.
Lawrence
%macro driver;
%if %sysfunc(day(%sysfunc(today()))) le 7 %then %do;
%a
%end;
%else %do;
"KILL PROGRAM" ?
%end;
%mend driver;
%driver
You have numerous options depending on just what you want to terminate, e.g., abend, abort and systask. Take a look at the following thread: http://www.mathkb.com/Uwe/Forum.aspx/sas/41557/Re-Kill-the-sas-program-if-it-runs-too-long
Ah yes-the good ole %abort function. Thanks & Have a great weekend!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.