Hello all, Novice user here. I am given the following data (patient ID, Adm_Date formatted mmddyy10, and Age) and must fill in the missing values for the variable age. I have only been able to calculate the first missing age for each patient ID (dates10/15/2006 and 10/01/2011), and I believe this is at least partially due to my use of the LAG function. Does LAG only work on the first value it references? Would using RETAIN statement or an array be more appropriate? I have not used an array previously. Any hints that would point me in the right direction would be greatly appreciated. Please avoid posting your complete solution, I'd like to figure out as much on my own as possible. Thanks! A11 12/10/2003 65.00
A11 10/15/2006 .
A11 07/20/2010 .
C02 05/11/2006 71.00
C02 10/01/2011 .
C02 07/03/2012 .
C02 05/08/2015 . PROC SORT DATA=AdmissionAge;
BY ID;
RUN;
DATA AGEFILL;
SET AdmissionAge;
BY ID;
prev_ADM_DATE=lag(ADM_DATE);
prev_AGE=lag(AGE);
IF NOT FIRST.ID AND AGE=. THEN
AGE = prev_AGE+((ADM_DATE-prev_ADM_DATE)/365.25);
FORMAT prev_ADM_DATE ADM_DATE MMDDYY10. AGE 5.2 ;
DROP prev_AGE prev_ADM_DATE ;
RUN;
My apologies for any formatting errors.
... View more