Hi everyone, I am trying to calculate number of years from baseline visit by subjects. Date format is mmddyy10. When I try the code below, it does the job for the first visit date (baseline) but not for the following visit dates (see results table at the end): proc sort data= have;
by ID Test_Date;
run;
data want;
set have;
length Visit 8.;
by ID Test_Date;
retain first.Test_Date;
if first.ID then do;
first.Test_Date = Test_Date;
end;
Visit = intck('year',first.Test_Date,Test_Date)+1;
format first.Test_Date Test_Date mmddyy10.;
run; ID Test_Date Visit 1 10/25/2011 1 1 11/05/2013 54 1 11/03/2015 56 1 11/07/2017 58 2 05/04/2011 1 3 06/02/2011 1 3 06/10/2013 54 3 06/15/2015 56 3 06/08/2017 58 Any suggestion will be much appreciated, Thank you! JJ
... View more