Help using Base SAS procedures

customer age question

Reply
N/A
Posts: 0

customer age question

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.
Super Contributor
Super Contributor
Posts: 3,174

Re: customer age question

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.
SAS Employee
Posts: 160

Re: customer age question

data test;
birth_txt = '20oct2000';
birth_sd = input(birth_txt,date9.); put birth_sd= date.;
age = intck('year',birth_sd,today()); put age=;
run;
Trusted Advisor
Posts: 2,113

Re: customer age question

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
SAS Employee
Posts: 160

Re: customer age question

Tx, for the link - Your right.
Ask a Question
Discussion stats
  • 4 replies
  • 136 views
  • 0 likes
  • 4 in conversation