|
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
|