@novinosrin, thank you and sorry for the confusion. My dataset includes multiple diagnostic codes from multiple facilities for each patient. I want to only keep observations (ID) for the FACILITY with the greatest number of diagnostic CODEs. data have; input ID FACILITY $ CODE SEVERITY; cards; 1 A 416000.1 1 1 A 751101.2 2 1 B 416000.1 1 2 A 416000.1 1 2 A 751101.2 2 2 B 416000.1 1 2 B 102000.1 1 2 B 102146.2 2 3 A 416000.1 1 3 A 751101.2 2 3 B 416000.1 1 3 B 416000.1 1 4 A 416000.1 1 4 A 751101.2 1 4 B 416000.1 1 4 B 416000.1 1; You have already helped me determine how to use SAS to select FACILITY 1A and 2B (since they have the most CODEs), but FACILITY 3 A/B and 4 A/B both have two CODEs. I would like to select FACILITY 3A because it has a greater total SEVERITY (1+2). The SEVERITY scores for facility 4 A/B are tied, so it doesn’t matter which I include. In the WANT dataset I just included first FACILITY (4A). WANT: 1 A 416000.1 1 1 A 751101.2 2 2 B 416000.1 1 2 B 102000.1 1 2 B 102146.2 2 3 A 416000.1 1 3 A 751101.2 2 4 A 416000.1 1 4 A 751101.1 1 Thank you again for sparing your valuable time to help!
... View more