hello,
i have given a code like this
data acl;
x=ceil(0.55);
y=floor(1.30);
z=round(1959.896);
d= put(mdy(x,y,z)+365,date9.);
run;
Here I am getting the output with these values:
x=1 y=1 z=1960 z=31dec1960
But why I am getting z value with in the same year even though i have given +365 days so this would result me with the value that is incremented to next year.
Kindly help me if I am missing anything here.
Leap years, 1960 is a leap year with 366 days, which is why you get Dec 31st.
data acl;
x=ceil(0.55);
y=floor(1.30);
z=round(1959.896);
d= put(mdy(x,y,z)+365,date9.);
d2 = intnx('year', mdy(x, y, z), 1, 's');
format d2 date9.;
d3 = d2;
format d3 ddmmyys10.;
run;
Here's a great, but longer and in depth, reference for dates and times in SAS
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/...
@meena_gowtham wrote:
hello,
i have given a code like this
data acl;
x=ceil(0.55);
y=floor(1.30);
z=round(1959.896);
d= put(mdy(x,y,z)+365,date9.);
run;
Here I am getting the output with these values:
x=1 y=1 z=1960 z=31dec1960
But why I am getting z value with in the same year even though i have given +365 days so this would result me with the value that is incremented to next year.
Kindly help me if I am missing anything here.
If you want to increment by a YEAR then tell SAS to do that.
d_string= put(intnx('year',mdy(x,y,z),1,'s'),date9.);
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.