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 (April 2005, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 30 Apr 2005 11:28:29 -0700
Reply-To:     shiling99@YAHOO.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         shiling99@YAHOO.COM
Organization: http://groups.google.com
Subject:      Re: How to find length of sequences of 1's in a column?
Comments: To: sas-l@uga.edu
In-Reply-To:  <1114860044.769357.143590@f14g2000cwb.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"

Since the data set is so simple, one pass with open data set once is possible. Construct two count variables, one for block obs, one for hold=1.

HTH

data t1; input hold; cards; 0 0 0 1 1 1 0 0 1 1 1 1 1 ;

data t2; set t1; by hold notsorted; if first.hold then do; freq_hold=0; cnt=0; end; freq_hold+hold; cnt+1; if last.hold then do; do i = 1 to cnt; output; end; end; keep hold freq_hold; run;

proc print; run;


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