I have a mapping specification for an analysis flag
"Flag any data required for safety summaries. Set ANL01FL to "Y" for: All scheduled visits from Week 1 to Week 16. If multiple records satisfy these conditions within a single analysis visit, select only the latest occurring visit to set ANL01FL to "Y". Scheduled visits are the visits which will be included in the summaries for this particular type of data."
This is a mock up sample of data for 2 subjects
This is what I have attempted
proc sort data=advs out=stage1; by usubjid paramcd avalc visitnum; run;
data want(rename=(_anl01fl = anl01fl));
do _n_ = 1 by 1 until (last.visitnum);
set stage1;
by usubjid paramcd avalc visitnum;
length _anl01fl $2;
_anl01fl = 'y';
end;
drop anl01fl;
run;
Anyone have any efficient recommendations/alternatives that doesn't involve too many proc sort/data steps?
