- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi there, I am just trying some thing with some data that i have and it seems that i am missing out on following few of the conditions while trying to flag the baseline records based on my following conditions.
1. if there are several records for a single test in a visit with the same result i need to flag the closest one to the target date.
2.if there are several records for a test on same visit with different results i need to flag the worst result as the baseline.
NOTE:R is the worst result for consideration
example data:
id test visit dy targetdy result
1 tst1 1 1 1 R
1 tst1 1 -29 1 R
1 tst1 1 1 1 S
I Am trying this code:
data xx;
set xx;
by id test visit result;
if result eq "S" then worstord=1;
else if result eq "R" then worstord=2;
run;
Proc sort data=xx; by id test visit worstord;run;
data blfl;
set xx;
by id test visit worstord;
if visit=1 and last.visit and worstord=2 then ABLFL="Y";
else if visit=1 and last.visit and worstord=1 then ABLFL="Y";
IF visit EQ 1 Then do;
if first.visit then numrec=1;
else numrec+1;
end;
run;
your help is much appreciated!!!!
Thanks alot
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @sandhya88, Thanks for providing some sample data that we can work with. Could you please show us what you want your dataset to look like?
Also, you mention date in reference to target date - is it supposed to be a date value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
thanks for looking at my data
here is what i wanted it to look alike
id test visit dy targetdy result baselineflg
1 tst1 1 1 1 R Y
1 tst1 1 -29 1 R
1 tst1 1 1 1 S
sorry for the text above please consider the closest dy to targetdy.
Thanks