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 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 19 Jun 2008 16:06:21 -0700
Reply-To:     "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM>
Subject:      Re: Comparing across respondents
In-Reply-To:  <200806191946.m5JHjG2C027473@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Consider something along the lines of

%LET v = 7; /*number of responses (variables) to check*/ %LET r = 5000; /*number of respondents*/

DATA new (KEEP = resp result1-result&r); ARRAY counts(&r,&r) TEMPORARY; ARRAY responses(&r,&v) TEMPORARY; ARRAY vars(&v) var1-var&v; ARRAY id(&r) TEMPORARY; ARRAY matches(&r) result1-result&r; DO i = 1 BY 1 UNTIL last; SET old END=last; id(i) = resp; DO j = 1 TO &v responses(i,j) = vars(j) END; END; last = i; DO i = 1 TO last; counts(i,i) = &v; DO j = i+1 BY 1 WHILE j <= last; DO k = 1 TO &v; IF responses(i,k) = responses(j,k) THEN DO; counts(i,j)+1; counts(j,i)+1; END; END; END; END; DO i = 1 TO last; resp=id(i); DO j = 1 TO last; matches(j) = counts(i,j); END; OUTPUT; END; STOP; RUN;

-----Original Message----- From: Prasad Samala [mailto:snip] Sent: Thursday, June 19, 2008 12:47 PM To: SAS-L@LISTSERV.UGA.EDU; Schwarz, Barry A Subject: Re: Comparing across respondents

On Thu, 19 Jun 2008 12:31:08 -0700, Schwarz, Barry A

>Do you mean you want a 5000 by 5000 element matrix? > >-----Original Message----- >From: Prasad [mailto:snip] >Sent: Thursday, June 19, 2008 11:08 AM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Comparing across respondents > >Hello everyone, > >I have a dataset with around 5000 respondents and around 10 variables. >A fragment of the dataset would look something like this... > >Resp var1 var2 var3 >101 1 3 3 >102 2 2 4 >103 2 1 2 >104 1 2 1 >105 2 3 3 >106 1 2 4 > >I need to create a matrix which looks like: > > 101 102 103 104 105 106 >101 3 0 0 1 2 1 >102 0 3 1 1 1 2 >103 0 1 3 0 1 0 >104 1 1 0 3 0 2 >105 2 1 1 0 3 0 >106 1 2 0 2 0 3

Yes. I would need a 5000 by 5000 element matrix whose elements are the counts I was explaining in my previous post


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