Date: Wed, 28 Jan 1998 11:51:37 -0600
Reply-To: txplltw@UABCVSR.CVSR.UAB.EDU
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Todd Weiss <txplltw@UABCVSR.CVSR.UAB.EDU>
Subject: Re: COUNT function in SAS
In-Reply-To: <9801281709.AA23781@UABCVSR.cvsr.uab.edu>
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hi Soumen,
There are other ways to do this, but the following
should work.
Regards,
Todd Weiss
__________________________________________________________________
%let arg = 1; *Use whatever numeric argument you want;
data test ( keep = x1 - x5 cnt );
array x ( 5 );
array tf ( 5 );
input x1 - x5;
do i = 1 to dim ( x );
tf ( i ) = x ( i ) = &arg;
end;
cnt = sum ( of tf1 - tf5 );
datalines;
1 2 3 1 1
1 4 3 2 1
2 3 1 2 4
;
proc print;
run;
On Wed, 28 Jan 1998, Soumen Mukherjee wrote:
> Is there a function in SAS that will count the number of arguments that
> match a specified value? For example lets say:
>
> x1 = 1
> x2 = 3
> x3 = 4
> x4 = 1
> x5 = 2
>
> Then a "count" function like
>
> result = count (of x1-x5, 1);
>
> should return a value of 2 for result.
>
> Thanks in advance for any help.
>
> Soumen.
>