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 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 12 Sep 2005 12:30:42 -0700
Reply-To:     David L Cassell <davidlcassell@MSN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         David L Cassell <davidlcassell@MSN.COM>
Subject:      Re: help on how to discontinue a test? thanks :-)
In-Reply-To:  <200509121812.j8CIBKIk005133@malibu.cc.uga.edu>
Content-Type: text/plain; format=flowed

meng4sas@gmail.com wrote: >I am trying to score a subtest. it has let's say 20 items(bds01-bds20). >give you a sample of the response will be like for one case. >11100100011100111100 >if I see 3 consecutive 0 in a row, I will need to discontinue the >test, which means that every item after that 3 consecutive 0s will be >changed 0 regardless this person answered them right or not. >so, for the above example, the scoring result should be >11100100000000000000 >Here is what I have right now. >it works. I am just wondering whether there is any other way to do it >or not(I am sure there will be other ways, I mean better ways :-) )

Umm, your code never made it into the list. Did you 'attach' a non-text file? That's a no-no. The list manager has to cut those things out to stop thousands of spam messages a week. You'd be better off just doing a simple cut-and-paste into the body of the message.

Since you don't actually have a binary string like:

11100100000000000000

but instead a series of numerics like this:

1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0

you could just stick with an array solution.

[If you had the data in a single string, like '11100100000000000000', then you could use INDEX() to find the first occurrence of '000' and then use that start value in a SUBSTR() call to turn the other values into zeroes. Like this UNTESTED code: length new $ 20; new = substr(old,1,index(old,'000'))||'00000000000000000'; But your data are not in this form.]

So for your data, you could write a do-loop like this:

array b{20} bds01-bds20; flag=0; do i1 = 3 to 19 (until flag=1); if b{i1}=0 & b{i1-1}=0 & b{i1-2}=0 then do; do i2 = i1+1 to 20; b{i2}=0; end; flag=1; end; end;

HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

_________________________________________________________________ Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


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