BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
UcheOkoro
Lapis Lazuli | Level 10

Please, I need to add a day to a particular date and my code is not working.

I am using the following code. 

Data Scheduling_data2b;
Set Scheduling_data;
if Start_date='5/31/2019'D then start_date2='6/1/2019'D;
run;

I would really appreciate some assistance.

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
IChatterji
Fluorite | Level 6

Please try:

Data Scheduling_data2b;
Set Scheduling_data;
if Startdate=input('05/31/2019',mmddyy10.) then start_date2= input('06/01/2019',mmddyy10.);
format start_date2 mmddyy10.;
run;

View solution in original post

4 REPLIES 4
jimbarbour
Meteorite | Level 14

@UcheOkoro,

 

Since it's a SAS date, you should be able to use the INTNX function to add a day.

 

Jim

jimbarbour
Meteorite | Level 14

Here's an example, below.  

 

By the way, I don't believe '5/31/2019'D will work as a date constant.  I believe it needs to be '31MAY2019'd (not case sensitive).

 

In the below example, only the date 31May2019 is incremented, and per your example, it is incremented by one day.

 

DATA	Scheduling_Data;
	Start_Date = '30apr2019'd;	OUTPUT;
	Start_Date = '31may2019'd;	OUTPUT;
	Start_Date = '30jun2019'd;	OUTPUT;
RUN;

Data Scheduling_data2b;
	FORMAT	Start_Date Start_Date2 MMDDYYS10.;
	Set Scheduling_data;
	if Start_date='31may2019'D then
		start_date2=intnx('day', Start_Date, 1);
	ELSE
		start_date2=Start_Date;
	PUTLOG	"NOTE:  "  Start_Date=  Start_Date2=;
run;

 

Log:

NOTE:  Start_Date=04/30/2019 Start_Date2=04/30/2019
NOTE:  Start_Date=05/31/2019 Start_Date2=06/01/2019
NOTE:  Start_Date=06/30/2019 Start_Date2=06/30/2019

Regards,

 

Jim

 

IChatterji
Fluorite | Level 6

Please try:

Data Scheduling_data2b;
Set Scheduling_data;
if Startdate=input('05/31/2019',mmddyy10.) then start_date2= input('06/01/2019',mmddyy10.);
format start_date2 mmddyy10.;
run;
UcheOkoro
Lapis Lazuli | Level 10

Thank you so much!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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
  • 4 replies
  • 1202 views
  • 0 likes
  • 3 in conversation