I would need to filter a dataset based on the higher value of var1 per each group.
I have this dataset:
Var1 t avg
AA 1 0.02
AA 0 0.21
BB 1 0.05
BB 0 0.20
CC 1 0.10
CC 0 0.14
Built as follows
Proc sql;
Select
Var1,
t,
Avg(var2) as avg
From my_data
Group by 1,2
Order by 1,2; quit;
My expected output would be
AA 0 0.21
BB 0 0.20
CC 0 0.14
Could you please give me some tips on how to do it? I think I should do something to rank them first, then select the observations having rank value = 1 (if in descending order)