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 (September 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 15 Sep 2005 14:21:31 -0400
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: help on translating Talbot Michael Katz's "discontinue a test
Comments: To: Dew Meng <meng4sas@GMAIL.COM>


Assuming there were some variable name changes and extra asterisks in your code, and that the following more closely approximates what your code looks like, the explanation is straight forward:

data tdm1; input teid age @7 (bds01-bds20)(1.); cards; 110 6 00011100011000010110 111 7 00100011000000000000 ; run;

data tdm2 ; set tdm1; array bds(*) bds: ; drop i triple ; triple = 0; do i = lbound(bds) to hbound(bds) ; if triple < 3 then triple =(triple + 1) * (bds{i} = 0) ; else bds{i} = 0 ; end ; run;

Triple serves as a counter of the number of consecutive 0s. It starts out as zero and, after it finds three consecutive 0s it sets all remaining bds values to 0.

The counter works by incrementing by 1 (i.e., triple=triple+1) if the current value is not zero, since it multiplies triple times the logical result (i.e., 0 if false, 1 if true) of whether the current value is equal to zero. So, if it finds a second consecutive zero, it makes triple equal to triple + 1 (or, in this case, 1+1=2) times 1 (since the current value is zero). If the current value was not equal to zero, then triple would be reset to zero.

Art ---------- Thu, 15 Sep 2005 12:30:43 -0500, mimi <meng4sas@GMAIL.COM> wrote:

> would you please help me on explaning the code that Talbot suggested on how >to discontinue a test. > Here is the situation. >I want to score all the items to 0s after 3 consecutive 0 occurs. >here is the fake data:

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