Hi SAS Community, I have a data set where I am trying to find the max grade for each ID. This is simple enough using Proc SQL and then using a group by statement. There are two problems that I am running into , the first is I am trying to identify the model where the max grade comes from and assign that model for each row with the same ID. In the example below, for ID #1 model b has a higher grade of 2 than a that only has a grade of 1, so model b would be assigned as the max_ model for ID #1.. The second problem that I am trying to tackle is the same as the first problem with an added nuance, If there are multiple models that have the same highest grade for the ID, I want to pick the one one with the highest amount value. In the example below, for ID #2 has two models have the same max grade of 3. Since model a has a higher value, I would assign a to every row for ID 2 This is an example of my data id model grade amount 1 a 1 10 1 b 2 10 2 a 3 20 2 b 3 10 This is what I envision my data to look like in the end id model grade amount max_grade max_model 1 a 1 10 2 b 1 b 2 10 2 b 2 a 3 20 3 a 2 b 3 10 3 a Please reach out if you have any questions or need me to clarify anything. Best, Tom
... View more