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 (February 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 26 Feb 2007 14:51:43 +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: modified version of counting obs
Comments:   To: sas_datalover@YAHOO.COM
In-Reply-To:   <539724.35513.qm@web62208.mail.re1.yahoo.com>
Content-Type:   text/plain; format=flowed

Syb ,

Untested Code

Data Need ( Keep = Id Count ) ; Set Have ; By Id Date ;

If First.ID Then Stop = 'N' ;

If ( Year( Date ) = 2004 ) And ( Stop Ne 'Y' ) Then Cnt + 1 ;

If Late > 30 Then Stop = 'Y' ;

If Last.Id Then Output ;

Run ;

Toby Dunn

To sensible men, every day is a day of reckoning. ~John W. Gardner

The important thing is this: To be able at any moment to sacrifice that which we are for what we could become. ~Charles DuBois

Don't get your knickers in a knot. Nothing is solved and it just makes you walk funny. ~Kathryn Carpenter

From: Syb it <sas_datalover@YAHOO.COM> Reply-To: Syb it <sas_datalover@YAHOO.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: Re: modified version of counting obs Date: Mon, 26 Feb 2007 06:42:31 -0800

I have a dataset that looks like the one below. There are two conditions I need to meet:

1) I want to count observations within a particular time period, in this case 2004. Everything outside that boundary I want to skip. 2) I want to stop counting by ID once I hit late gt 30.

So in the example data set below, for ID 1 I should have a count of 2, for ID=2, count is 3. ID=3 count is 2, ID = 5 count is 2. So for observations within 2004, once I hit late > 30 I want to stop counting, and ignore the rest of the information for that ID.

Any suggestions?

title 'counting observations within 2004'; data test; input id date:date9. late; format date date9.; datalines; 1 1-Sep-04 0 1 2-Oct-04 1 1 5-Dec-04 63 1 1-Jan-05 -4 1 3-Mar-05 62 2 1-Jan-04 0 2 13-Feb-04 12 2 5-Mar-04 -8 2 12-Apr-05 7 3 3-Mar-04 0 3 4-Apr-04 1 4 3-Jun-04 0 5 1-Sep-04 0 5 3-Oct-04 2 5 14-Nov-04 41 5 15-Jan-05 61 5 16-Feb-05 1 ;;;; run; proc print data=test; run;

Thank you.

--------------------------------- Any questions? Get answers on any topic at Yahoo! Answers. Try it now.

_________________________________________________________________ With tax season right around the corner, make sure to follow these few simple tips. http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips.aspx?icid=HMFebtagline


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