First, I do have a variable, year of birth (i.e. without days and months of births). Second, I would like to derive age from the stated variable based on today’s date. I’ve attempted the derivation using the following code but I’ve been unsuccessful.
Data myage;
set suvdata;
AGE=floor(YRDIF(RB080, today(),"AGE"));
run;
I shall be most grateful for your help.
The YRDIF function want two date values. So use the MDY function to create date
AGE=floor(YRDIF(mdy(1,1,RB080), today(),"AGE"));
would use January 1 as the date in the year.
The YRDIF function want two date values. So use the MDY function to create date
AGE=floor(YRDIF(mdy(1,1,RB080), today(),"AGE"));
would use January 1 as the date in the year.
@ballardw, Thank you so very much.
@Zacc wrote:
First, I do have a variable, year of birth (i.e. without days and months of births).
So in other words, you just have the year of birth, is that what you are saying? The value of your variable might look like 1978.
So you would compute the age via
data want;
set have;
age = 2022 - rb080;
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.