BookmarkSubscribeRSS Feed
☑ This topic is solved. 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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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