Help using Base SAS procedures

How do i find DOB with start date and age?

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How do i find DOB with start date and age?

[ Edited ]

Need assistance finding DOB with a start date and age. Also has to include a do loop. 

 

Age is 40.

Start date is February 15, 2001.

 

My script so far:

 

data birth;

     Age = 40;

     Start = '15Feb2001'd;

Bday=Start-Age;

do Age = 1 to 90 until (Start lt '15Feb2001'd);

     output;

          end;

run;

 

proc print data=birth;

format Start Bday mmddyy10.;

run; 


Accepted Solutions
Solution
‎11-13-2017 09:38 PM
Super User
Posts: 23,724

Re: How do i find DOB with start date and age?

You can tell the year and the month, sort of, but you cannot determine the exact date. 

 

And the solution still doesn't need arrays or loops so, in context of how you originally framed the question, it still doesn't add clarification. 

 

If you want the answer to this question, use INTNX to move the date back by the age. 

You can look at the fourth parameter for some alignment options, but really the birthdate can be anything in the range of a year. 

 

dob = intnx('year', date, -40, 'b');

 

 

View solution in original post


All Replies
Super User
Posts: 23,724

Re: How do i find DOB with start date and age?


asobs wrote:

Need assistance finding DOB with a start date and age. Also has to include a do loop. 

 

Age is 40.

Start date is February 15, 2001.

 

My script so far:

 

data birth;

     Age = 40;

     Start = '15Feb2001'd;

Bday=Start-Age;

do Age = 1 to 90 until (Start lt '15Feb2001'd);

     output;

          end;

run;

 

proc print data=birth;

format Start Bday mmddyy10.;

run; 

 

 

 


DOB doesn't change over time...why do you think you need a do loop for that?

New Contributor
Posts: 3

Re:

[ Edited ]

T

Super User
Posts: 23,724

Re: How do i find DOB with start date and age?

Well...the question as posed doesn't make sense so I'm not sure how we can help you here. 

New Contributor
Posts: 3

Re:

[ Edited ]
 
Solution
‎11-13-2017 09:38 PM
Super User
Posts: 23,724

Re: How do i find DOB with start date and age?

You can tell the year and the month, sort of, but you cannot determine the exact date. 

 

And the solution still doesn't need arrays or loops so, in context of how you originally framed the question, it still doesn't add clarification. 

 

If you want the answer to this question, use INTNX to move the date back by the age. 

You can look at the fourth parameter for some alignment options, but really the birthdate can be anything in the range of a year. 

 

dob = intnx('year', date, -40, 'b');

 

 

Super User
Posts: 23,724

Re: Re:

Thank you for reminding me why I should never bother with stupid and homework questions. 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 315 views
  • 0 likes
  • 2 in conversation