Hi guys,
I've got a bit of a sticky problem here. I need to calculate the mode (most common value) across about half a dozen columns. There doesn't seem to be a "MODE" function though.
I was hoping I could do something like this:-
but there's no MODE function.
It looks like I'm going to need to manually code this. Does anyone have any ideas? The data was originally given to me transpose, so I could have used Proc Univariate to get the mode out, however, there are 41,000 records, which became 41,000 columns, which SAS can't handle (it truncated at 32,767 columns).
Does anyone have any code, or an algorithm for working out the mode?
Cheers
Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
I've got a bit of a sticky problem here. I need to calculate the mode (most common value) across about half a dozen columns. There doesn't seem to be a "MODE" function though.
I was hoping I could do something like this:-
Code:
data _null_;
a = 1;
b = 4;
c = 4;
d = 6;
e = 10;
f = 12;
g = 13;
median = median(a,b,c,d,e,f,g);
put median=;
mode = mode(a,b,c,d,e,f,g);
put mode=;
run;
It looks like I'm going to need to manually code this. Does anyone have any ideas? The data was originally given to me transpose, so I could have used Proc Univariate to get the mode out, however, there are 41,000 records, which became 41,000 columns, which SAS can't handle (it truncated at 32,767 columns).
Does anyone have any code, or an algorithm for working out the mode?
Cheers
Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.