BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vidyasagar1
Obsidian | Level 7

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

Kurt_Bremser
Super User

@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).

Tom
Super User Tom
Super User

@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?

vidyasagar1
Obsidian | Level 7

Hi All, please help me to write a code for this.

PaigeMiller
Diamond | Level 26
%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));

 

--
Paige Miller
vidyasagar1
Obsidian | Level 7

Thanks a lot. This solution is working for me . 🙂

vidyasagar1
Obsidian | Level 7

Hi, sorry how to exclude the list of holidays also from that expression ?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 21 replies
  • 2078 views
  • 2 likes
  • 4 in conversation