LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 1998, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 12 May 1998 15:16:16 -0400
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         "Mark D. H. Miller" <mdmiller@SYR.EDU>
Organization: Syracuse University, FACSS
Subject:      Re: "Count" in SAS
Content-Type: text/plain; charset=us-ascii

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 <> Faculty Computing and Media Services Tel: 315.443-2143 272 Newhouse Communications Center II Fax: 315.443-5658 Syracuse University Syracuse, NY 13244-2110 *-------------------------------------------------------------*

Back to: Top of message | Previous page | Main SAS-L page