BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
elladunn
Calcite | Level 5

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


1 ACCEPTED SOLUTION

Accepted Solutions
Scott_Mitchell
Quartz | Level 8

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.

View solution in original post

5 REPLIES 5
Scott_Mitchell
Quartz | Level 8

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 DOA:DATE9. DOB:DATE9.;

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

elladunn
Calcite | Level 5

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?

Gratefully appreciate your guidance.

Regards

Ella

Scott_Mitchell
Quartz | Level 8

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.

elladunn
Calcite | Level 5

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

Regards

Ella

Scott_Mitchell
Quartz | Level 8

No worries Ella.  Glad that it helped.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2762 views
  • 4 likes
  • 2 in conversation