たとえば、次のようなデータセットがあります。
id Date
1 2000/01/01
1 2001/01/01
1 2002/01/01
2 2003/01/01
datastep または sql で、id = 1 で最新の日付が 2002/01/01 のレコードを取得するにはどうすればよいですか? 助けていただければ幸いです。事前に感謝します。
このSQLを試してください。
select id,max(Date)
from yourtable
group by id;
これも試すことができます
proc sql;
create table my id as
select id,Date
from yourtable
where Date=(select max(Date) where id = 1 )
quit
/*Sort your data by id and descending date then*/
data want;
set have;
by id; /* you don't need to specify date here */
if first.id;
run;