BookmarkSubscribeRSS Feed
sandhya88
Calcite | Level 5

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

2 REPLIES 2
maguiremq
SAS Super FREQ

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?

sandhya88
Calcite | Level 5

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

 

 

 

 

 

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 792 views
  • 0 likes
  • 2 in conversation