Date: Wed, 25 May 2011 08:39:09 -0700
Reply-To: "Jfh@alumni.stanford.org" <jfh@STANFORDALUMNI.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Jfh@alumni.stanford.org" <jfh@STANFORDALUMNI.ORG>
Subject: Re: How to count the number of a particular character in a
Content-Type: text/plain; charset=UTF-8
Have you looked at the CountC function?
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
"DUELL, BOB (ATTCINW)" <bd9439@ATT.COM> wrote:
Hi, I was asked today how to count how many of a particular character was in a string and came up with the following: data _null_; tester = 'alphabet characters'; do check_for = 'a','z'; count = ifn(index(tester,check_for),length(compress(tester,check_for,'k')),0); put check_for= count=; end; run; This certainly works but it involves a lot of function calls. Any better (more efficient) ideas? Thanks, Bob