<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />嗨伙计,
我有一个数据集,其中包含 20 年时间段内的每日雪深数据。 我需要按年份确定峰值或最大雪深值发生的日期。 关于如何实现这一点的任何建议?谢谢。
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />有很多方法可以解决您的问题。首先,让我们以 sashelp.class 为例,使用 'sex' 相当于您的 'year','height' 相当于您的 'snow depth':
1. SQL解决方案:
进程sql;
创建表想要作为
从 sashelp.class a 中选择 a.*,
(按性别从 sashelp.class 组中选择性别,最大值(高度)作为最大值) b
其中 a.sex=b.sex 和 a.height=b.max
;
退出;
2. 数据步骤;
proc sort data=sashelp.class out=tem;
按性别;
跑;
需要数据(drop=_h);
做直到(last.sex);
设置时间;
按性别;
_h=max(_h,height);
结尾;
做直到(last.sex);
设置时间;
按性别;
如果高度=_h 则输出;
结尾;
跑;
当然,还有许多其他方式值得研究,例如 proc summary 等:
proc摘要数据=sashelp.class nway;
阶级性别;
变量高度;
output out=want (drop=_:) maxid(height(name) height(age) height(weight))=name age weight max= ;
跑;
问候,
海阔