sorting - 使用与 SAS 中另一列中的值相对应的日期列
问题描述
我想添加到此代码中,以便根据“测量”列中的“日期”列的最后一次测量值除以测量列中记录的最小值,结果形成一个新列。如果“主题”、“类型”和“程序”列匹配,当前的工作代码会添加一个列,该列从“测量”列中的其他测量值中减去初始测量值。先感谢您。
data have;
input Subject Type Date $ 5-12 Procedure $ 15-22 Measurement;
datalines;
500 Initial 15 AUG 2017 Invasive 20
500 Initial 18 SEPT 2018 Surface 35
500 Followup 12 SEPT 2018 Invasive 54
428 Followup 2 JUL 2019 Outer 29
765 Seventh 3 JUL 2018 Other 13
500 Followup 6 NOV 2018 Surface 98
428 Initial 23 FEB 2018 Outer 10
765 Initial 20 AUG 2019 Other 19
610 Third 21 AUG 2018 Invasive 66
610 Initial 27 Mar 2018 Invasive 17
;
data want (drop=rc _Measurement);
if _N_ = 1 then do;
declare hash h (dataset : "have (rename=(Measurement=_Measurement) where=(Type='Initial'))");
h.definekey ('Subject');
h.definedata ('_Measurement');
h.definedone();
end;
set have;
_Measurement=.;
if Type ne 'Initial' then rc = h.find();
NewMeasurement = ifn(Measurement=., ., sum (Measurement, -_Measurement));
run;
解决方案
推荐阅读
- r - 在R中使用udpipe提取关键字时的for循环
- android - 为什么这个分页库示例的性能比仅仅一个回收器视图差得多?
- android - Lenovo Smart Display 或 Google Home Hub 上的 Android Things?
- java - 是否可以开发一个 Android 服务来准确查看其他应用程序打开了哪个视图?
- php - pdo_sqlanywhere macOS 莫哈韦
- java - 对象数组空检查
- java - 如何在for循环中取前2个元素然后跳过第三个元素java
- python - 通过 SSH 推送文本文件命令的 Python 脚本
- laravel - 一对一雄辩的关系
- wagtail - 如何在原始 wagtail 管理导航栏中使用“子菜单”创建“根菜单”?