BookmarkSubscribeRSS Feed
meena_gowtham
Calcite | Level 5

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. 

2 REPLIES 2
Reeza
Super User

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. 


 

Tom
Super User Tom
Super User

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.);

AI Navigator GIF.gif


Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.

Check it out on Microsoft Marketplace →

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
  • 2 replies
  • 1727 views
  • 1 like
  • 3 in conversation