BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
asobs
Calcite | Level 5

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; 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

6 REPLIES 6
Reeza
Super User

@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?

asobs
Calcite | Level 5

T

Reeza
Super User

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

asobs
Calcite | Level 5
 
Reeza
Super User

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

 

 

Reeza
Super User

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

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1208 views
  • 0 likes
  • 2 in conversation