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
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
|