BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello, I have a simple question regarding determining a customers age based on their birth date. In my records the birthdate is included in the ddmmmyyyy format. I would like to determine their age as a new variable in the table. Do I have to reformat it and check it against SAS's internal calender to determine this? How would I go about doing this? thanks for any help anyone can provide.
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The answer is: "it depends". If you birthdate variable is a character-type, you will need to convert it to a SAS numeric DATE variable using the INPUT function and the appropriate SAS DATE INFORMAT. However, if a SAS PROC CONTENTS on your SAS database file indicates that this variable is SAS NUMERIC and is using some SAS format to display (externally) the formatted value, then you can use SAS functions, such as INTCK, to determine age.

Have a look at the SAS support website http://support.sas.com/ and the SAS Base documentation in the SAS Language guide. Also, at the support site (using the SEARCH option), there are technical papers (SUGI, SGF - user group conference proceedings) which explore this topic in great detail.

Scott Barry
SBBWorks,Inc.
GertNissen
Barite | Level 11
data test;
birth_txt = '20oct2000';
birth_sd = input(birth_txt,date9.); put birth_sd= date.;
age = intck('year',birth_sd,today()); put age=;
run;
Doc_Duke
Rhodochrosite | Level 12
INTCK will not produce age as you and I think of it, as it only counts whole calendar years and not duration between the birthday and some date. Once you have your dates into date format, use this technique

http://support.sas.com/kb/24/808.html

Doc Muhlbaier
Duke
GertNissen
Barite | Level 11
Tx, for the link - Your right.

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