| Date: | Thu, 11 Sep 1997 10:30:26 EDT |
| Reply-To: | "Mr. Juggie Mistry CUUKMAIL MS - 22702/27411"
<juggie_mistry@UK.CU.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | "Mr. Juggie Mistry CUUKMAIL MS - 22702/27411"
<juggie_mistry@UK.CU.COM> |
| Subject: | REF: RE: FUNCTION TO COUNT WORDS.... |
| Content-Type: | text/plain; charset=US-ASCII |
/*====================================================================
! !
! Name : M_WC.SAS !
! Type : Base SAS Macro !
! Date : 29th April 1997 !
! !
! Purpose : Counts number of words in a string !
! !
! Author : Jugdish Mistry-Professional Solution Providers Ltd.!
! Version : 1.0 !
! !
! Run mode : Interactive !
! Passed in : None !
! Passed out : None !
! !
! Maintanance History !
! !
! When Who What !
! !
====================================================================*/
%macro wc(string);
%let word=%scan(&string,1);
%let wc=0;
%do %while(%quote(&word) ne %quote());
%let wc=%eval(&wc+1);
%let word=%scan(&string,&wc);
%end;
&wc;
%mend;
/* e.g.
data _null_;
x = %wc(once upon a time);
put x=;
run;
*/
Hope this helps
Juggie.
Juggie Mistry
SAS consultant I12
|