BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

View solution in original post

7 REPLIES 7
art297
Opal | Level 21

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

_LB
Fluorite | Level 6 _LB
Fluorite | Level 6

Thanks Art.

That helps. I was close but was missing an element or two.

_LB
Fluorite | Level 6 _LB
Fluorite | Level 6

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

art297
Opal | Level 21

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.,

http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/viewer.htm#programstatements_se...

_LB
Fluorite | Level 6 _LB
Fluorite | Level 6

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

art297
Opal | Level 21

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

_LB
Fluorite | Level 6 _LB
Fluorite | Level 6

Ah yes-the good ole %abort function. Thanks & Have a great weekend!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 975 views
  • 0 likes
  • 2 in conversation