Phan,
I failed to mention that the code I suggested requires SAS 9.3. I presume you are on an older version.
Dear Art,
Thanks for the follow-up. Indeed, I am working on 9.3.
In fact, this message from log file: character values have been converted to numeric values at the places given by ... referred for another (I'm sorry to confuse you).
Lately, I will send you a log file that may help you to understand the issue when I ran the code.
I am in Vancouver, a bit inconvenience at my workplace for Internet.
Phan
Not a problem. I'm in Toronto thus at least your response won't have to go through Customs.
Dear Art,
Please kindly see the log. I will see a stat person tomorrow morning and will fu you.
8617 /*person-year*/
8618 py_dead1=yrdif(farvdt, death_date, 'act/act');
8619 py_dead2=datdif(farvdt, death_date, 'act/act');
8620
8621
8626 run;
NOTE: Invalid argument to function YRDIF at line 8618 column 10.
NOTE: Invalid argument to function DATDIF at line 8619 column 10.
Thanks,
Phan
Are both farvdt and death_date SAS date fields? All three of the following work for me:
data have;
informat farvdt death_date date9.;
input farvdt death_date;
/*person-year*/
py_dead1=yrdif(farvdt, death_date, 'act/act');
py_dead2=datdif(farvdt, death_date, 'act/act');
py_dead3=yrdif(farvdt, death_date, 'age');
cards;
1jan2010 10may2012
10jun2011 25oct2012
;
Dear Art, good morning!
Pls. kindly see the date SAS. I will fu with you late today, I hope to show the issue to my colleague. Thanks.
Phan
DEATH_
Obs ID FARVDT DATE
16 310 01MAR2010 .
17 340 28APR2008 .
18 350 22NOV2006 27MAR2008
19 360 23FEB2004 .
20 370 07OCT2009 .
You would get the error due to the missing dates. What date would you base person_years on for someone who hasn't died?
Dear Art,
You are absolutely correct!
I use another date (as this dataset is a bit confusion) the dead_date do not reflect for death and I am asked to use fu_time. And the code work fine.
I much appreciate and thank you very much, Art, and thanks everyone's times for discussion.
Phan S.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.