Date: Fri, 1 Dec 2006 02:41:31 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: count the length of a sequence of ones and zeros
In-Reply-To: <1164940233.687959.167460@j72g2000cwa.googlegroups.com>
Content-Type: text/plain; format=flowed
Leong ,
Data Need ( Keep = MyTS Cnt ) ;
TS = '1100011111000' ;
Do I = 1 To LengthC( TS ) ;
MyTS = Substr( TS , I , 1 ) ;
If MyTS = '0' Then Cnt = 0 ;
Else Cnt + 1 ;
Output ;
End ;
Run ;
Proc Print
Data = Need ;
Run ;
Toby Dunn
Quickly, bring me a beaker of wine, so that I may wet my mind and say
something clever.
Aristophanes
Wise people, even though all laws were abolished, would still lead the same
life.
Aristophanes
You should not decide until you have heard what both have to say.
Aristophanes
From: Leong <leongfin@GMAIL.COM>
Reply-To: Leong <leongfin@GMAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: count the length of a sequence of ones and zeros
Date: Thu, 30 Nov 2006 18:30:33 -0800
Hi,
I have a time sereis of ones and zeros, for instance
11000111110001......
above sequence can be viewed as runs of ones and runs of zeros, that
is:
first run: 1 1
second run 0 0 0 0
third run 11111
fourth run 0 0 0
.......
I am only interested in the position of one in a given run.
I would like to have a SAS program that can tell me the position of
each one in all the runs ( the position of zeros can be treated as
either zero or misssing value)
i.e.
TS position
1 1
1 2
0 .
0 .
0 .
1 1
1 2
1 3
1 4
1 5
0 .
0 .
0 .
....
thanks a lot
Leong.
_________________________________________________________________
Get free, personalized commercial-free online radio with MSN Radio powered
by Pandora http://radio.msn.com/?icid=T002MSN03A07001