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 ?
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.