Date: Tue, 12 May 1998 15:16:16 0400
ReplyTo: mdmiller@syr.edu
Sender: "SAS(r) Discussion" <SASL@UGA.CC.UGA.EDU>
From: "Mark D. H. Miller" <mdmiller@SYR.EDU>
Organization: Syracuse University, FACSS
Subject: Re: "Count" in SAS
ContentType: text/plain; charset=usascii
For simulating in SAS, the SPSS Count function, I've always taken
advantage of the versatility of logical expressions in SAS which
return a value of zero or one depending on whether the expression
is false or true. Consequently several logical expressions in the
same statement can be summed, differenced, etc. Hence to handle
the example given by the original requestor, Luying Wei,
who wrote:
>
> >>There is a "count" function in SPSS. Suppose x1 and x2 are two
> >>variables, then the following command in SPSS
> >>count y = x1 x2 (1) gives the occurrences of value 1 in variables x1
> >>and x2 and store it into variable y.
> >>
I would use
y = (x1=1) + (x2=1);
This form is flexible enough to handle most (if not all) the chores for
which the SPSS function would be used. Moreover, it allows one to use
generate "counts" where the set of criterion expressions involves mixed
variable types, (i.e. both character and numeric variables) as in
z = (x1=1) + (x2=1) + (S3='ABC');
SPSS requires that all criterion variables be of the same type.

**
Mark D. H. Miller <mdmiller@syr.edu>
Faculty Computing and Media Services Tel: 315.4432143
272 Newhouse Communications Center II Fax: 315.4435658
Syracuse University Syracuse, NY 132442110
**
