I have a table as below
level1 level2
furniture chair
furniture chair
furniture table
food pizza
I want to get unique level 1 variable and highest occurring level 2 variable for that variable. Output:
level1 level2
furniture chair
food pizza
Summarize data to get counts, PROC FREQ.
Sort into order to get the counts descending by level1.
Use a data step and BY group processing to get the first observations for each level1.
proc freq data=have order = freq;
table level1*level2 / out=counts;
run;
proc sort data=counts;
by level1 descending Count;
run;
data want;
set counts;
by level1;
if first.level1;
run;