BookmarkSubscribeRSS Feed
jerry898969
Pyrite | Level 9

I have a column that has text in each row.  I was assigned to find the mode of this column by my manager.  I have never heard of mode in this respects so i'm not sure how I would calculate it in sas.  Any help would be great appreciated.

6 REPLIES 6
Reeza
Super User

proc freq and sort descending will get you the most freq. I think there's an option to set it to sort descending.

jerry898969
Pyrite | Level 9

Reeza,

Thank you for your help I will try that out.  Is there a proc that can give me mean, median and mode all at once? If not what would be the best approach to calcualte mean and median?

Thank you so much

Reeza
Super User

For a text variable?

I don't know how mean or median for those would be applicable.

Mode makes some sort of sense to find the most frequent comment or word.

For numeric variables, use proc means/summary/univariate.

jerry898969
Pyrite | Level 9

Sorry I didn't explain it better.  It is the length of the text field I need these statistics for.  I will try those procs thanks.

ballardw
Super User

Data want;

     set have;

     VarLength=length(variablename of interest);

run;

proc means data=want mean median mode;

var Varlength;

run;

Prit
Calcite | Level 5

In three ways you can calculate mean, mode and median of numeric variable.

1) Proc menas data=<dataset_name> mean mode median;

    var <variable_names>;

     run;

2) Proc summary data=<dataset_name> print mean mode median;

    var <variable_names>;

     run;

3) ODS select basicmeasures;

     Proc univariate data=<dataset_name>;

     var <variable_names>; 

     run;

Check it out.

-Prit

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 941 views
  • 0 likes
  • 4 in conversation