Hi, Thank you for trying to help me. But my expected output is like below :
For the first two models today's date and for next four models incrementing the date by 1 and so on. Also should not consider weekends and list of holidays we provide.
Expected Output:
Model Build_Date
735 11/16/2021
736 11/16/2021
737 11/17/2021
777 11/18/2021
775 11/19/2021
772 11/22/2021
773 11/23/2021
787 11/23/2021
797 11/24/2021
747 11/25/2021
@vidyasagar1 wrote:
Hi, Thank you for trying to help me. But my expected output is like below :
For the first two models today's date and for next four models incrementing the date by 1 and so on. Also should not consider weekends and list of holidays we provide.
Expected Output:
Model Build_Date
735 11/16/2021
736 11/16/2021
737 11/17/2021
777 11/18/2021
775 11/19/2021
772 11/22/2021
773 11/23/2021
787 11/23/2021
797 11/24/2021
747 11/25/2021
My first code (which you accepted as solution) does it for 3 observations in the alternating package; adapting it to 4 is child's play. If it is not so for you then I fear you are just not equipped to work with SAS code (or doing programming in a broader sense).
@vidyasagar1 wrote:
Hi, Thank you for trying to help me. But my expected output is like below :
For the first two models today's date and for next four models incrementing the date by 1 and so on. Also should not consider weekends and list of holidays we provide.
Expected Output:
Model Build_Date
735 11/16/2021
736 11/16/2021
737 11/17/2021
777 11/18/2021
775 11/19/2021
772 11/22/2021
773 11/23/2021
787 11/23/2021
797 11/24/2021
747 11/25/2021
I do not see the pattern. Can you pleas explain how you are deciding when to move to a new date?
Hi All, please help me to write a code for this.
%let today=%sysfunc(today());
%let replication=2;
data want;
set input;
date=intnx('weekday17W',&today,floor((_n_-1)/&replication));
format date mmddyy10.;
run;
You can change the value of &REPLICATION, right now it is set to 2, so every two observations will have the same date, and the next observation will be the next weekday. By changing &REPLICATION, you get most of what you have asked for.
If you set &REPLICATION to 2.5, the first 3 records will have the same date, and then the next 2 records will have the next weekday, and so on. If you want the first 2 records to have the same weekday, and then the next 3 records to have the same weekday, set &REPLICATION to 2.5 and then make the calculation of date via the following:
date=intnx('weekday17W',&today,floor((_n_-1e-6)/&replication));
Thanks a lot. This solution is working for me . 🙂
Hi, sorry how to exclude the list of holidays also from that expression ?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.