DATA Step, Macro, Functions and more

Run a program twice in a day only

Reply
Frequent Contributor
Posts: 85

Run a program twice in a day only

Hi All,

I need to schedule a sas program in batch and at the max program should be run twice in a day. I need a control table for sure but how to get the logic is something i am not getting.

Contro table structure is something like

program_nameTime_When_runDateCountFlag
abc9AM7-Nov-1311
abc12AM7-Nov-1321

So my flag is set to 0 at beginning of the day say at 00:00 and it gets set to 1 when program is run successfully.

How do I get it done? Thanks in advance

Super User
Posts: 5,257

Re: Run a program twice in a day only

Can you describe what problem you are facing? Is the scheduling part, or updating the control table?

Usually I use macro calls for this, when the jobs starts, create row, when job ends, update with end status or whatever information you need.

Data never sleeps
Frequent Contributor
Posts: 85

Re: Run a program twice in a day only

Hi Linus ,

I have problems in scheduling and confusion in updating control table.  Confusion is what should flag be by end of day and how to get information for next day. SAY  today job run twice successfully and its flagged as 1. So how do I set flag as 0 tomorrow.

Super User
Posts: 5,257

Re: Run a program twice in a day only

Scheduling: what scheduling tool will you use? What kind of SAS product are available for you (intelligence platform...?) What platform are you on?

Logging: use the start datetime for the job as a key. Each execution of the job will have it's own row. It will be easy to see when a job has not started at all. Who will look into this log table?

Data never sleeps
Frequent Contributor
Posts: 85

Re: Run a program twice in a day only

We have LSF. However my client is curious to know if we execute this manually in DI job. There certainly is user written code in that and say two different users run this code in shift times. Morning guy in morning n evening guy in evening.

My question still remains same. How should I get flags correct. Some sample code would be extremely helpful.  Log table is also under our control its structure is also not defined so we can manipulate the way we want to

Super User
Posts: 5,257

Re: Run a program twice in a day only

Running manually in DIS is not really scheduling... ;-)

%macro adrec(job);

proc sql;

     insert into control.joblog (program_name, time_when_run, date_when_run, flag)

          (&Job, "&SysTime"t, "&SysDate9"dt, 0)

     ;

quit;

%mend adrec;

%macro change_flag(job, time = &SysTime, date = &SysDate);

proc sql;

update control.joblog

     set flag = 1

     where job_name = "&Job" and time_when_run="&Time"t and date_when_run="&Date"d

     ;

quit;

%mend change_flag;

Untested... see as an idea.

Can't figure out what you want to store count, could easily be created when querying the log table.

Data never sleeps
SAS Employee
Posts: 10

Re: Run a program twice in a day only

Hi forumsguy,

Of course. to state the obvious, running the job directly from within DIS has the same effect as running the job from a scheduler, just not scheduled.

Scheduling a job to run twice a day is straight forward using SMC Schedule Manager (when it is fronting a Platform LSF scheduler instance). Do you need help doing that?

Ask a Question
Discussion stats
  • 6 replies
  • 501 views
  • 0 likes
  • 3 in conversation