Hi, there I am curious how to achieve this in SAS. My data is sorted by id and date. for id "a", if the days between date in row 3 and row 4 is equal to 3, then I want to copy var1 to var2. Otherwise, in case id"b", if the days between date in row 3 and row 4 is not equal to 3, then leave it blank. Thanks in advance!!! data have;
infile cards dlm=',';
Input ID$ date :ddmmyy10. var1 var2;
format date YYMMDDn8.;
cards;
a, 01/01/2018, . ,111,
a, 02/01/2018, . ,111,
a, 03/01/2018, . ,111,
a, 06/01/2018, 222 ,.,
a, 07/01/2018, 222 ,.,
b, 08/01/2018, . ,111,
b, 09/01/2018, . ,111,
b, 10/01/2018, . ,111,
b, 11/01/2018, 222 ,.,
b, 12/01/2018, 222 ,.,
;
run;
data want;
infile cards dlm=',';
Input ID$ date :ddmmyy10. var1 var2;
format date YYMMDDn8.;
cards;
a, 01/01/2018, . ,111,
a, 02/01/2018, . ,111,
a, 03/01/2018, . ,111,
a, 06/01/2018, 222 ,222,
a, 07/01/2018, 222 ,.,
b, 08/01/2018, . ,111,
b, 09/01/2018, . ,111,
b, 10/01/2018, . ,111,
b, 11/01/2018, 222 ,.,
b, 12/01/2018, 222 ,.,
;
run;
... View more