Solved
New Contributor
Posts: 3

# Negative age values

Hi people of the SAS procedures community.

I am a v new student to SAS and feel caught in the  headlights while having my toenails pulled! I believe it gets better........

Anyway after a few hours I need help, pls excuse if this is such a painfully basic question;

Have date of birth(dob) and date of acceptance(doa) into a program.  Some of the patients were born before 1960 so I am getting negative values when I calculate their age at date of acceptance.   Would be eternally grateful for any guidance.

Using
input dob mmddyy9. doa mmddyy9.
agea=yrdif(dob,doa,'AGE');

Yours in eternal indebtedness

Ella

Accepted Solutions
Solution
‎09-26-2013 01:53 AM
Super Contributor
Posts: 312

## Re: Negative age values

The following article explains the issue quite nicely.

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

Let me know if you have any further questions.

All Replies
Super Contributor
Posts: 312

## Re: Negative age values

Hi Ella,

Welcome to the wonderful world of SAS.

I have created the following to replicate what you are seeing.

DATA HAVE;

FORMAT DOA DOB DATE9.;

INPUT DOAATE9. DOBATE9.;

DATALINES;

01JAN1994 01JAN1959

01JAN1994 01JAN1960

01JAN1994 01JAN1961

;

RUN;

DATA WANT;

SET HAVE;

AGEA=YRDIF(DOB,DOA,'AGE');

RUN;

The results this achieves are what you would expect I suspect.  Is there a chance that the DOA is larger than the DOB in the circumstances where you have witnessed negative resutls?

If you post an example of the data you are accessing it will assist us in helping you.

Regards,

Scott

New Contributor
Posts: 3

## Re: Negative age values

Hi Scott

Thank you very much for your prompt response. And YES I have just noticed that some years are being read incorrectly eg 1914 has been read as 2014 which of course would make the difference negative in fact it is only years less than 1919 that are been converted to 2000's and then have negative values.  Oh boy am I missing something really important here?

Regards

Ella

Solution
‎09-26-2013 01:53 AM
Super Contributor
Posts: 312

## Re: Negative age values

The following article explains the issue quite nicely.

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

Let me know if you have any further questions.

New Contributor
Posts: 3

## Re: Negative age values

Thanks soooooooooo much Scott, all sorted now, really appreciated the prompt and informative response.

Regards

Ella

Super Contributor
Posts: 312

## Re: Negative age values

No worries Ella.  Glad that it helped.

🔒 This topic is solved and locked.