The SAS Output Delivery System and reporting techniques

Select value over multiple nested conditions

Reply
New Contributor
Posts: 2

Select value over multiple nested conditions

How can i select a correct Group_ID who has to be satisfied following conditions:

 

1a) If # of visits = 1 then select "TIE" Group_ID with most recent Max_date

 

1b) else If # of visits = 1 AND Max_date is the same date then select "TIE" Group_ID with greatest Cost

1c) else If # of visits = 1 AND most recent Max_date is the same date AND Cost is the same then leave blank

2a) else if # of visits > 1 then select "TIE" Group_ID with greatest time

 

2b) else If # of visits > 1 AND Time is equal then select "TIE" Group_ID with Max_date .

 

2c)  else If # of visits > 1 AND time is equal AND the Max_date is the same then select "TIE" Group_ID with greatest Cost.

 

2d) else If # of visits > 1 AND length of time between first and last E&M visits is equal AND the Max_date is the same AND the Cost are the same then leave blank.

My data is below:
IDPeriod Group_IDEM countsMin_dateMax_dateCosttime
AAA14Q493612/3/20152/4/201500
AAA166532124/9/201424/9/201500
AAA266532222/7/20137/3/2014$228 228
AAA2454936128/2/201428/2/201400
AAA24Q493618/1/20138/2/201301
AAA31829265/5/201428/4/20150358
AAA318252615/5/201428/4/2015358348.00
Grand Advisor
Posts: 10,215

Re: Select value over multiple nested conditions

First thing: Define "visit"

Second: how do we identify " "TIE" Group_ID"

Third: "Max_date is the same" same as ? Max_date or Min_date

Fourth: "AND Time is equal" equal to what, assumes you mean value to time but which ones may not be obvious

For you example data, what would the output look like?

If you don't have an example of each case of your conditions it can be hard to test code.

New Contributor
Posts: 2

Re: Select value over multiple nested conditions

First thing: Define "visit" ----Visit is EM count

Second: how do we identify " "TIE" Group_ID" ---TIE is having same EM counts, or Max_date, or Cost or Time

Third: "Max_date is the same" same as ? Max_date or Min_date-----Max_date is the same as Max_date

Fourth: "AND Time is equal" equal to what, assumes you mean value to time but which ones may not be obvious ---Time is calculated by the Max_date substract Min_date

My output is to find the winner group ID for each period.  for example, in period 1 both group IDs had same EM counts of 1, then follow rule 1a and 1b  the second one has most recent Max_date, so the Group ID= 66532 is the winner for period 1, and so on...

Please let me know if it's still not clear.

Thanks,

V.

Ask a Question
Discussion stats
  • 2 replies
  • 372 views
  • 0 likes
  • 2 in conversation