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.
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;
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
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;
Thank you so much!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.