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 (June 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 27 Jun 2001 15:45:45 +0200
Reply-To:     "Tribius, Heide" <Heide.Tribius@KFW.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Tribius, Heide" <Heide.Tribius@KFW.DE>
Subject:      Re: Counting routine
Comments: To: "Lee_Medoff@READERSDIGEST.COM" <Lee_Medoff@READERSDIGEST.COM>
Content-Type: text/plain; charset="iso-8859-1"

data test; id=1; var1=1; var2=0; var3=0; output; id=2; var1=1; var2=1; var3=0; output; id=3; var1=0; var2=0; var3=1; output; run;

data neu; set test; array num _numeric_; do _i_=1 to dim(num); if num(_i_) = 1 then count = sum(count,1); end; if id = 1 then count = count - 1; run;

hope it helps. Heide

-----Original Message----- From: Lee_Medoff@READERSDIGEST.COM [mailto:Lee_Medoff@READERSDIGEST.COM] Sent: Wednesday, June 27, 2001 3:08 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Counting routine

Dear Sas-L:

I am looking to create a routine, within SAS, that for each record will count the number of variables with a value greater than one. By way of example,

ID Var1 Var2 Var3 1 0 0 1 2 1 0 1 3 1 0 0

and so on.

The counter (which should be a new variable) for ID 1 would equal one, ID 2 would equal 2, etc.

Any suggestions? Please post response directly to my e-mail adrress.

TIA,

Lee Medoff


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