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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 301 views
  • 1 like
  • 3 in conversation