How to Calculate the Mode in SAS

104 14

    PROC UNIVARIATE

    • 1). Prepare input dataset.

    • 2). Select a procedure. Depending on the version of SAS, several procedures allow use of MODE: PROC MEANS, PROC TABULATE, PROC REPORT and PROC UNIVARIATE. UNIVARIATE is sufficient for the purpose of finding the modes of all fields in the input dataset.

    • 3). Program the procedure. Sample syntax for finding the mode is:
      PROC UNIVARIATE DATA=DATASET1 MODES ROUND=1 0.5 0.5;
      var age height weight;
      run;
      The MODES option makes a table of all possible modes, i.e. for every variable listed under VAR that has at least two values the same. The procedure's default is to display only one variable's mode. Replacing MODES with MODE outputs only one variable's mode.
      Replacing MODES with ALL leads to output of a table of modes as well as many other statistics.
      The ROUND= option reduces the number of unique variable values, thereby reducing the memory requirement. The 1 rounds age to the nearest year. The two 0.5s round height and weight to the nearest half.

    • 4). Save the program, then submit it for execution.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.

"Society & Culture & Entertainment" MOST POPULAR

Ways to Use Sea Glass

How to Biscuit Joints

Making a Kite: Tie Support Sticks

A Typical Plant's Cell Structure

How to Increase Specific Gravity

How the Eye Perceives Color

Major Effects of Global Warming