Date: Wed, 15 May 2002 11:20:19 -0700
Reply-To: prasad.s.ravi@HOUSEHOLD.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Prasad Ravi <prasad.s.ravi@HOUSEHOLD.COM>
Subject: Re: Count across the row
Content-type: text/plain; charset=us-ascii
I am not sure if this counts as an easy way but you could do this in a data
step.
DATA ONE;
INPUT ID v1 $ v2 $ V3 $ V4 $ V5 $;
DATALINES;
1 E E E . 3
2 E . . 2 E
;
RUN;
PROC SORT DATA=ONE;
BY ID;
RUN;
DATA TWO;
SET ONE;
BY ID;
TOTAL_COUNT=0;
COUNT_E=0;
ARRAY VARS (*) V1-V5;
DO I=1 TO DIM(VARS);
TOTAL_COUNT+1;
IF VARS(I)='E' THEN COUNT_E+1;
PCT_E=(COUNT_E/TOTAL_COUNT)*100;
END;
DROP I;
IF LAST.ID THEN OUTPUT;
RUN;
PROC PRINT;
RUN;
OUTPUT
TOTAL_
Obs ID v1 v2 V3 V4 V5 COUNT COUNT_E
PCT_E
1 1 E E E 3
5 3 60
2 2 E 2 E
5 2 40
Prasad Ravi
qjiang To: SAS-L@LISTSERV.UGA.EDU
<qjiang@GMCF.ORG> cc:
Sent by: "SAS(r) Subject: Count across the row
Discussion"
<SAS-L@LISTSERV.U
GA.EDU>
05/15/2002 10:55
AM
Please respond to
qjiang
Hi all,
I have a PROC COMPARE output data set with about 400 variables compared.
The data set is like:
ID v1 v2 V3 V4 V5
1 E E E . 3
2 E . . 2 E
.....
Is there an easy way to count the percent of equals ?
My expected output
ID %eq
1 60%
2 40%
Thanks in advance.
Qin