BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
helpmedoubts
Fluorite | Level 6
Write a program to calculate your date of birth if your age is 30.
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

The previous posts all raise valid points.  Let's take a look at your code a bit more closely.

 

You move back 365 * 30 days.  That's only approximately correct.  A block of 30 years will contain approximately 7 leap years, where that year contains 366 days.  So a more accurate attempt would be:

 

DOB = intnx('year', today(), -30, 'same');

 

That moves back to the same day of the year as the current date, 30 years ago.  And as was pointed out, there will be many valid dates that fit the bill.  This calculation gives you one of those valid dates.

View solution in original post

6 REPLIES 6
helpmedoubts
Fluorite | Level 6
Data want;
DOB=today()-365*30;
Format dob date9.;
Run;
Reeza
Super User
You cannot get an exact date of birth. You know the date of birth is within 364 days of the 30 years from today but not the exact date.
You would need more specific information to answer this correctly.
Astounding
PROC Star

The previous posts all raise valid points.  Let's take a look at your code a bit more closely.

 

You move back 365 * 30 days.  That's only approximately correct.  A block of 30 years will contain approximately 7 leap years, where that year contains 366 days.  So a more accurate attempt would be:

 

DOB = intnx('year', today(), -30, 'same');

 

That moves back to the same day of the year as the current date, 30 years ago.  And as was pointed out, there will be many valid dates that fit the bill.  This calculation gives you one of those valid dates.

helpmedoubts
Fluorite | Level 6

Thanks a lot for explaining it so well. The code worked perfectly.

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
  • 6 replies
  • 755 views
  • 0 likes
  • 4 in conversation