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
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.
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
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
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.
Thanks soooooooooo much Scott, all sorted now, really appreciated the prompt and informative response.
Regards
Ella
No worries Ella. Glad that it helped.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: