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 (March 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 5 Mar 2002 07:51:48 +1300
Reply-To:   Don Stanley <don_stanley@XTRA.CO.NZ>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Don Stanley <don_stanley@XTRA.CO.NZ>
Subject:   Re: counting of specific values in a var row
Comments:   To: Annette <anne5432@UNI.DE>
Content-Type:   text/plain; charset=us-ascii

something like ...

data ; set or read your file ; array countvars {*} var1--var? ; new= 0 ; do i=1 to dim(countvars) ; new = new + (countvars(i)=1 or counter(i)=2) ; end ; run ;

syntax probably not exactly right ..

Don

Annette wrote: > > dear SAS list, > I have a data set in the following structure: > VAR1 VAR2 VAR3 VAR4 > 1 5 3 1 > 3 2 3 3 > 4 5 1 3 > All I want to do is to count the freqs of 1s and 2s in a row, and to add > their sum in a var NEW > VAR1 VAR2 VAR3 VAR4 NEW (sum of 1s and 2's in VAR1 to VAR4) > 1 5 3 1 2 > 3 2 3 3 1 > 3 4 8 7 0 > 4 5 1 2 2 > The real dataset contains dozends of vars. > Your help is greatly appreciated! > Annette

-- Don Stanley, B.SC, Dip O.R.S, MNZCS EMAIL:: don_stanley@xtra.co.nz, don@sysware.co.nz Author:: Beyond the obvious with SAS Screen Control Language. Author:: Solutions for your GUI Applications Development Using SAS/AF FRAME Technology http://www.sysware.co.nz , http://www.geocities.com/don_stanley_nz/don_home.htm


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