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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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