From: Patrick on
data have;
input date:yymmdd10. trade;
datalines;
1991-02-10 15
1991-02-16 25
1991-06-25 36
1992-02-25 23
1992-06-12 54
;
run;

/* version 1 */
title1 'Version 1';
proc sql;
select year(date) as year, month(date) as month, date, trade
from have
group by year,month
having max(date)=date
;
quit;

/* version 2 */
title1 'Version 2';
proc sql;
create view Vwant2 as
select year(date) as year, month(date) as month, date, trade
from have
order by year,month,date
;
quit;

data want2;
set Vwant2;
by year month date;
if last.month then output;
run;
proc print data=want2 noobs uniform;
var year month date trade;
run;
From: oloolo on
data want;
if _n_=1 then do;
declare hash h();
h.defineKey('Year', 'Month');
h.defineData('Year', 'Month', 'Day', 'trade');
h.defineDone();
end;
set have;
Year=Year(date); Month=Month(date); _Day=day(date);
if h.find()^=0 then h.add();
else do;
if _Day>day then do; Day=_day; h.replace(); end;
end;
run;


On Tue, 15 Dec 2009 02:25:36 -0800, siyuan li <lisiyuan0753(a)GMAIL.COM>
wrote:

>On 12Ԃ15ȕ, ςΧ12ʱ26?֬ siyuan li <lisiyuan0...(a)gmail.com> wrote:
>> hi,all, now I have a dataset like that:
>> date trade
>> 1991-02-10 15
>> 1991-02-16 25
>> 1991-06-25 36
>> 1992-02-25 23
>> 1992-06-12 54
>> the problem is I want to find out the trade every month of every year.
>> can help me?
>> thanks
>
>Firstly I must say sorry. I want to find out the trade that the last
>day of every month of every year.
From: Tom Abernathy on
That sounds like a Calendar issue. Trades usually do not happen when
the market is closed. So the last trading day of the month is most
likely note the last day in the month.

I suggest just manually creating a format or informat with the last
trading day of each month and use it to test the dates in you file.

For example:
proc format ;
invalue lastday
'27JAN1991'd = 1
'25FEB1991'd = 1
other = 0
;
run;
data lasttrade;
set trade;
if input(date,lastday.) then output;
run;

On Dec 15, 5:25 am, siyuan li <lisiyuan0...(a)gmail.com> wrote:
> On 12ÔÂ15ÈÕ, ÏÂÎç12ʱ26·Ö, siyuan li <lisiyuan0....(a)gmail.com> wrote:
>
> > hi,all, now I have a dataset like that:
> > date trade
> > 1991-02-10 15
> > 1991-02-16 25
> > 1991-06-25 36
> > 1992-02-25 23
> > 1992-06-12 54
> > the problem is I want to find out the trade every month of every year.
> > can help me?
> > thanks
>
> Firstly I must say sorry. I want to find out the trade that the last
> day of every month of every year.