×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Run a subset of code based on weekday

Run a subset of code based on weekday

Run a subset of code based on weekday

(OP)
I have a large set of code that update various datasets daily.
Part of the code need to only run on Mondays so I want to write some kind of an if statement to check for today's date and run only if today is Monday  weekday(date)=2?

RE: Run a subset of code based on weekday

If I am not wrong you yourself have found the solution
you can use weekday function as weekday(today()) or weekday(&sysdate)

Or else you can create a separate sas code file for that code and schedule is weekly once on monday using some scheduling tool like if u are using UNIX u can schedule on cron tab

sasbuddy
http://sites.google.com/site/sasbuddy/
 

RE: Run a subset of code based on weekday

(OP)
Thanks for your reply. I know which function to use however, not sure how to use it in a SAS proc. Here is what I've been trying to do but it doesn't seem to work:

data _null_;
If WEEKDAY(TODAY()) = 1 then do;
%Include '\Data\CODE\Reports.sas';
end;
run;

This seem to run no matter what the day is. not sure what I am doing wrong.

Thanks for your help.

RE: Run a subset of code based on weekday

If you are aware of macros, I wish u can give try with it;
create a macro of the code which u have included in Reports.sas file and call that macro inside if condition.

One more thing instead of '=' sign you can try using eq for comparison.

I hope this would work. Best Luck.   

sasbuddy
http://sites.google.com/site/sasbuddy/
 

RE: Run a subset of code based on weekday

Using a SAS Macro:

%MACRO Depend ;
%If %SYSFUNC(WEEKDAY(%SYSFUNC(TODAY()))) = 1 %then
%do;

<CODE HERE>

%END ;
%MEND Depend ;



You could also use a call execute:

Data _NULL_ ;
IF WEEKDAY(TODAY())=1 THEN
CALL EXECUTE ("<Code within quotes here>") ;
RUN;

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close