Programming the statistical procedures from SAS

Mode calculation across variables

Occasional Contributor
Posts: 10

Mode calculation across variables

I have 20 different values for the same person from different sources (Stored in 20 variables Age1, Age2, ... Age20) and need to select one final value of age. We decided to go with Maximum occurred value (Mode) of age. If the person has one mode then that's the value or if more than one then randomly pick one. To do this I need to calculate Mode across variables as we calculate Mean or Sum(Age1, Age2,...Age20) using SAS Function. I couldn't find similar function for calculating MODE. I can transpose and calculate modes for each sub-group but the problem is dataset is very large (4-million records and 20 variables) and I need their mode recombined to their IDs. So better way is if I can find MODEs. across the variables Is there any way to calculate this?

Frequent Contributor
Posts: 96

Re: Mode calculation across variables

You might be able to adapt the technique discussed here:


"Calculating Mean, Median and Mode with SQL Server"

SAS 9.4 (TS1M4) X64_7PRO WIN 6.1.7601 Service Pack 1 Workstation

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation