Dear all,
May you help me to find what is wrong with my statement below?
I tried to generated the last Column with correct date , however, the statement generated column " Line start date new " which is wrong at the highlight column.
data test9;
set test8;
retain line_start_date_new;
if summerge=1 then line_start_date_new=lag(line_start_date);
else if missing(summerge) then line_start_date_new=.;
run;
Yesterday, I got help codes here, which generated correct results. But I do not understand how my codes are different from the help codes below. 😞
data test9;
set test8;
retain line_start_date_new ;
line_start_date_new = ifc(summerge=1, lag(line_start_date), line_start_date_new);
if missing(summerge) then call missing(line_start_date_new);
run;
| PatientID | Line start date | Line end date | summerge | Line start date new ( wrong) | Line start date new (correct) |
| A | 4/21/2015 | 4/24/2015 | 1 | . | |
| A | 8/12/2015 | 8/31/2015 | . | . | |
| A | 11/5/2015 | 11/5/2015 | . | . | |
| A | 1/12/2016 | 4/26/2016 | . | . | |
| A | 6/7/2016 | 9/20/2016 | 1 | 4/21/2015 | 1/12/2016 |
| A | 10/5/2016 | 11/2/2016 | 2 | 4/21/2015 | 1/12/2016 |
| A | 1/31/2017 | 1/31/2017 | . | . | . |
| A | 5/4/2017 | 5/4/2017 | 1 | 6/7/2016 | 1/31/2017 |
| A | 11/14/2017 | 1/10/2018 | 2 | 6/7/2016 | 1/31/2017 |
| B | 1/16/2014 | 6/19/2014 | . | . | . |
| B | 7/10/2014 | 9/4/2014 | . | . | . |
| B | 10/9/2014 | 5/14/2015 | . | . | . |
| B | 6/8/2015 | 6/8/2015 | 1 | 5/4/2017 | 10/9/2014 |
| B | 9/24/2015 | 9/24/2015 | . | . | . |
| B | 1/25/2016 | 3/7/2016 | . | . | . |
| B | 3/24/2016 | 8/25/2016 | 1 | 6/8/2015 | 1/25/2016 |
| B | 10/14/2016 | 2/17/2017 | 2 | 6/8/2015 | 1/25/2016 |