BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I need to calculate age for a dataset, but all I have is year of birth and the date they entered the program. I need to calculate the approximate age each sample was when they entered the program based on the year of his/her birth and the date they entered the program. I just am not sure the correct program to do this. I know how to do this with two actual dates, but not from a year and a date. Thank you for any help provided.

JH
3 REPLIES 3
darrylovia
Quartz | Level 8
With only the Birth year available your options are limited, but for estimation purposes we can make a stab at it.

SAS has "parsing" functions for date/datetime values. My example below uses the YEAR function to extract the year from the date the subject entered the program. Let me know if this is the direction that you want to go.


data _null_;

year_of_birth=1982;
program_year=year(today());

guesstimate_of_age=program_year-year_of_birth;

put _all_;
run;

Regards
D
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The SAS language functions YEAR, MONTH, DAY (for DATE component extraction) and to assign a SAS DATE variable consider using MDY function. Check the SAS Language DOC, also using SAS Dates conference/technical papers found on the SAS support website.

Scott Barry
SBBWorks, Inc.


Suggested Google advanced search arguments, this topic / post:

using dates tutorial site:sas.com

date functions year month day mdy site:sas.com

data step programming date variables site:sas.com
Ksharp
Super User
Hi.
What does your data look like ? especial your age and date?
And I think the most important thing is the weight of each month you want to set.
If you want set weight of each month to 1 (i.e. everyone birth at each month has the same probability.
So It base on your prior - probability to each month.


Ksharp

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1544 views
  • 0 likes
  • 4 in conversation