proc sql;
create table pay1 as
select id, due_date
from table1
quit;
data pay2;
set pay1;
BreakDate=due_date+5 /*Example if the due_date is 05/25/2013 this variable returns 05/30/13*/
run;
My question is, I use macro that automatically accounts for previous business day. If a day falls on Sunday, the macro &pbd will assign a Monday date. For example &pbd+5 will return an number value for 5 days after the previous business day. I then can format it to look like an actual date.
I need to incorporate due_date and &pbd together to produce the next business days after the 5 days has elapsed. For example if I use the formula in my program:
If the due_date=05/14/13,the BreakDate will equal 5/19/13, which is Sunday. I want to default to Monday. I need to use both the due_date and &pbd to accomplish this. Or is there an easier way? Perhaps just say if the BreakDate falls on Sunday, automatically increment to Monday?
use intnx with the 'weekday' option. But this won't account for holidays, so if yours does then its better.
intnx('weekday', '14May2013'd, 5);
how about the last logic,
If the Breakdate falls on Sunday, automatically increment to Monday.
data _null_;
break_date='19may2013'd;
if weekday(break_date)=1 then break_date=break_date+1;
put break_date date9.;
run;
hi ,
Try this..
data want (drop =i);
informat break_date date9.;
format break_date date9.;
do i = 1 to (3*30);
Break_date=intnx('days','01Apr2013'd,i);
if weekday(break_date) = 1 then
break_date=intnx('days',break_date,1);
output;
i=i+4;
end;
run;
Regards,
Allu
Hi,
It is simple by using DATA Step as follow...
data test(drop = _temp);
format due_date break_date date9.;
due_date = "01Jan2013"d;
break_date = due_date + 5;
_temp = weekday(break_date);
if _temp = 1 then do;
break_date = due_date + 6;
end;
else do;
break_date = break_date;
end;
run;
-Urvish
What is in the macro variable &BPD ?
1) How is it formatted? If it is formatted as DATE9. format outputs data then you can use it as a date literal in your SQL statements. For Example: if break_date= "&BPD"d.
2) What does the value of BPD represent? Is it one number that will apply to all observations? If not then you need a way to get the value of BPD that is right for the current observation. Perhaps by creating a separate table you can merge onto your data? Or a format?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.