LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (January 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 13 Jan 2006 20:43:12 -0800
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: trying to output last 8 rows of each month
Comments:   To: sas-l@uga.edu
In-Reply-To:   <20060114010538.39131.qmail@web80003.mail.yahoo.com>
Content-Type:   text/plain; charset="iso-8859-1"

I attached the example below.

The pgm will output upto 8 rows records at last date of each month.

Hope this helps.

data t1; length date 8 class 8 level $8 count 8; informat date mmddyy8.; format date date9.; input date : class : level : count ; cards; 020603 1 8z 12 020603 1 16z 13 020603 1 9z 15 020603 1 10z 14 020603 2 8z 20 020603 2 12z 31 020603 2 14x 41 020603 2 15z 44 020703 1 8z 12 020703 1 16z 13 020703 1 9z 15 020703 1 10z 14 020703 2 8z 20 020703 2 12z 31 020703 2 14x 41 020703 2 15z 44 022803 1 8z 12 022803 1 16z 13 022803 1 9z 15 022803 1 10z 14 022803 2 8z 20 022803 2 12z 31 022803 2 14x 41 022803 2 15z 44 ;

data t2; set t1; by date ; n+1; if first.date then cnt=0; cnt+1; lastday=intnx('month',date,0,'end'); if last.date and lastday=date then do; do point=n-min(8,cnt) + 1 to n; set t1 point=point; output; end; end; drop cnt n lastday; run;

proc print; run;

David Fickbohm wrote: > People, > I have a file containing data from feb 2003 until the present. > Each day 8 rows are added to the file. > I want to output 8 rows from the last day of each month from feb 2003 until the present. > The data looks like this > date class level count > 020603 1 8z 12 > 020603 1 16z 13 > 020603 1 9z 15 > 020603 1 10z 14 > 020603 2 8z 20 > 020603 2 12z 31 > 020603 2 14x 41 > 020603 2 15z 44 > 020703 1 8z 12 > 020703 1 16z 13 > 020703 1 9z 15 > 020703 1 10z 14 > 020703 2 8z 20 > 020703 2 12z 31 > 020703 2 14x 41 > 020703 2 15z 44 > more days of data > 022803 1 8z 12 > 022803 1 16z 13 > 022803 1 9z 15 > 022803 1 10z 14 > 022803 2 8z 20 > 022803 2 12z 31 > 022803 2 14x 41 > 022803 2 15z 44 > > I want the output to look like: > 022803 1 16z 13 > 022803 1 9z 15 > 022803 1 10z 14 > 022803 2 8z 20 > 022803 2 12z 31 > 022803 2 14x 41 > 022803 2 15z 44 > > all ideas will be greatly appreciated. > Thanks > Dave > > > > > > > Dave Fickbohm > > Use Technology to the Fullest > 1250 45th st suite 200 > Emeryville, CA, 94608 > 510 594 4151 voice


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