BookmarkSubscribeRSS Feed
vivudao
Calcite | Level 5

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
2 REPLIES 2
ballardw
Super User

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.

vivudao
Calcite | Level 5

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 872 views
  • 0 likes
  • 2 in conversation