turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- How to calculate mode for length

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-11-2012 12:15 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jerry898969

12-11-2012 12:19 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

12-11-2012 01:56 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jerry898969

12-11-2012 02:02 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

12-11-2012 02:44 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jerry898969

12-11-2012 06:32 PM

Data want;

set have;

VarLength=length(variablename of interest);

run;

proc means data=want mean median mode;

var Varlength;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jerry898969

12-12-2012 01:31 AM

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