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 (January 2011, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 11 Jan 2011 13:56:40 -0800
Reply-To:   Jack <jacksas001@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jack <jacksas001@GMAIL.COM>
Subject:   Re: Identify ties for values of variables
In-Reply-To:   <201101111940.p0BILijZ030086@wasabi.cc.uga.edu>
Content-Type:   text/plain; charset=ISO-8859-1; format=flowed

Hi Shukla

You already have many useful suggestions from other experts. Here is my way using array with loop reduction. That means that once a pair of equal values are found the loop will be terminated and move to next observation. I hope that speeds large data set manipulations a little bit.

data test; input b1-b8; datalines; 2 0 5 6 3 0 0 0 3 0 4 0 0 3 2 0 0 2 0 4 5 7 9 1 1 4 1 0 1 0 4 5 0 1 3 0 4 5 6 6 ; run;

data obtain (drop=i j); set test; flag=0; array b{8} b1-b8; do i=1 to 7; do j=1 to 8-i; if b{i} eq b{i+j} and b{i} ne 0 then do; flag=1; leave; end; end; end; run;

Best, Zhaoyan

On 1/11/2011 11:40 AM, Shukla Kshirsagar wrote: > I have 8 brands in a dataset, with possible values of 0-9 for each of them. > > I want to write macro code, where I can look for ties in the values of the > brands, and create a flag. > e.g if brand1=brand2 or brand1=3 or......brand1=brand8 > or brand2=brand3........ > then flag=1 > > b1 b2 b3 b4 b5 b6 b7 b8 flag > 2 0 5 6 3 0 0 0 0 > 3 0 4 0 0 3 2 0 1 > > > Thanks for your help, > Shukla >


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