| Date: | Mon, 26 Feb 2007 06:42:31 -0800 |
| Reply-To: | Syb it <sas_datalover@YAHOO.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Syb it <sas_datalover@YAHOO.COM> |
| Subject: | Re: modified version of counting obs |
|
| In-Reply-To: | <B89C5B3C26FDEF4CA2BCBFAFC411AF82F4BDD9@PFGDSMMBX015.principalusa.corp.principal.com> |
| Content-Type: | text/plain; charset=iso-8859-1 |
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.
|