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.);
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.