BookmarkSubscribeRSS Feed
Sathish_jammy
Lapis Lazuli | Level 10

Hi Experts,

 

Kindly go through my sample dataset for the clear picture.

 

data aaa;
input Id Vdate mmddyy10. visit;
format Vdate date9.;
cards;
12 10/11/2012 1
12 02/08/2013 2
12 01/09/2013 3
12 01/01/2014 4
63 05/06/2010 1
63 02/08/2010 2
63 07/11/2011 3
63 09/09/2011 4
;

data bbb;
input Id Rdate mmddyy10. BP;
format Rdate date9.;
cards;
12 10/11/2012 89
12 04/08/2013 56
12 05/09/2013 78
63 05/06/2010 45
63 06/08/2010 12
63 08/11/2011 32
63 09/09/2011 65
;

/*
OP
ID VDate    Visit	RDate	   BP
12 10/11/2012 1  	10/11/2012 89
12 02/08/2013 2		04/08/2013 56
12 01/09/2013 3		05/09/2013 78
12 01/01/2014 4		.			.
63 05/06/2010 1		05/06/2010 45
63 02/08/2010 2		06/08/2010 12
63 07/11/2011 3		08/11/2011 32
63 09/09/2011 4		09/09/2011 65
*/

I need to update the BP value through the matched date. 

I updated the step where VisitDate and RecordDate are the same.

But I failed to match the case where the RecordDate is > VisitDate. 

In those cases, I need to update the value of Rdate in between the Vdates. 

For reference, I placed the required OP.

 

Thanks in advance!

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

In your request, all of your RecordDate is > VisitDate. What if that was not the case?

 

If your data is representative, you can simply do

 

data want;
   call missing(BP);
   merge aaa bbb;
   by ID;
run;
Sathish_jammy
Lapis Lazuli | Level 10

Thanks for your quick and effective response.

I want to implement conditions like : 

Condition1 : Vdate = Rdate - (I done)

Condition 2: if Vdate < Rdate but that date in between its next Vdate ?????

I need to use these conditions as a SAS data step...

Sorry! if I trouble you...

 

I tried sql pattern as:

update ccc
set Rdate = b.Record_date,
BP = b.BloodPressure
FROM ccc a JOIN bbb b
ON a.ID = b.ID and
b.Rdate = a.Vdate

 

update ccc
set Rdate = b.Record_date,
BP = b.BloodPressure
FROM ccc a JOIN bbb b
ON a.ID = b.ID and Rdate is null and BP is null
b.Rdate between (the Vdate and nxt Vdate) ??????

I cant specify the date here Its differs for each IDs So Please suggest to specify this condition.Thanks in adv

 

 

 

Astounding
PROC Star

Instead of showing your program that didn't work, explain what result you would like to see and the reasoning that makes it the right result.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 964 views
  • 0 likes
  • 3 in conversation