I Found It in the Forum

August 27, 2008
By

This post was kindly contributed by Key Happenings at support.sas.com - go there to comment and to read the full post.

Whew! I’ve been speeding around information stops all over the Web. That’s quite a workout. As alluded to in my last post, you can find really useful information in some unlikely places. Given that I challenged you to broaden your Internet stops, I’ve been trying to do the same. Because time is limited, accepting that challenge for myself meant that I ignored my usual stomping grounds. Feeling traitorous, I returned to them this morning and right away found a gem to share with you. I found this gem on my way through the SAS discussion forums.

Cynthia@sas responds to a poster in the SAS Procedures forum who asked “Is there a way to count the frequency of strings within a character variable?” Cynthia provides a short SAS program that performs a frequency count of the words in the first chapter of Melville’s Moby Dick. In her post, she writes:

Interestingly enough, after you eliminate all the articles and prepositions and pronouns, the most frequently used word in the first chapter of Moby Dick is ‘sea’ (13 times) followed by ‘water’ (8 times). The words ‘ship’, ‘soul’, ‘man’ and ‘whale’ each occur 3 times. Anyway, the relevant part of that program is shown below — I had to get rid of a stray ‘?’ in the chapter, which is why the compress is in the code. Also, I turned everything to lower case, so ‘The’ and ‘the’ would get counted the same when I did a frequency on the WORD variable.

See the post to get the code. Anybody want to count the words in the speeches given at the two political conventions?

This post was kindly contributed by Key Happenings at support.sas.com - go there to comment and to read the full post.

Tags: ,

Welcome!

SAS-X.com offers news and tutorials about the various SAS® software packages, contributed by bloggers. You are welcome to subscribe to e-mail updates, or add your SAS-blog to the site.

Sponsors







Dear readers, proc-x is looking for sponsors who would be willing to support the site in exchange for banner ads in the right sidebar of the site. If you are interested, please e-mail me at: tal.galili@gmail.com
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.