🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Fluorite | Level 6

## DOB

Write a program to calculate your date of birth if your age is 30.
1 ACCEPTED SOLUTION

Accepted Solutions
PROC Star

## Re: DOB

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.

6 REPLIES 6
Super User

## Re: DOB

What have you tried so far? Please post your code.

Fluorite | Level 6

## Re: DOB

Data want;
DOB=today()-365*30;
Format dob date9.;
Run;
Super User

## Re: DOB

Looks good to me. Have a look at the INTNX function for an alternative.

Super User

## Re: DOB

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.
PROC Star

## Re: DOB

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.

Fluorite | Level 6

## Re: DOB

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

Discussion stats
• 6 replies
• 933 views
• 0 likes
• 4 in conversation