SAS问题以基于组删除行
我有2个数据集,
我需要SAS查询
Table 1
ID Prin Int Tot TranType TranDt
101 100 15 115 P 1/1/2021
101 100 15 115 P 1/1/2021
102 500 15 515 P 5/1/2021
103 300 15 315 P 6/1/2021
104 250 10 260 P 8/1/2021
105 350 10 360 P 9/1/2021
105 300 10 310 P 10/1/2021
Table 2
ID Prin Int Tot TranType TranDt
101 100 15 115 R 1/15/2021
103 300 15 315 R 6/2/2021
105 350 10 360 R 9/5/2021
105 300 10 310 R 10/5/2021
最终输出的
Table 3
ID Prin Int Tot TranType TranDt Cat
101 100 15 115 P 1/1/2021 Rev
101 100 15 115 P 1/1/2021 Good
102 500 15 515 P 5/1/2021 Good
103 300 15 315 P 6/1/2021 Rev
104 250 10 260 P 8/1/2021 Good
105 350 10 360 P 9/1/2021 Rev
105 300 10 310 P 10/1/2021 Rev
帮助,我需要组合表1和表2,以及(ID prin int tot)和trantype = p的组合 匹配表2(id prin int tot)和trantype = r然后 如果应将重复标记为好,则将该行标记为Rev,但第二行。 输出如表3所示。 只要它是> = table1.trandt,表2的trandt就很好。
感谢此查询的任何帮助。
我尝试分组,但我无法使其起作用。
I have 2 datasets
I need help with SAS query
Table 1
ID Prin Int Tot TranType TranDt
101 100 15 115 P 1/1/2021
101 100 15 115 P 1/1/2021
102 500 15 515 P 5/1/2021
103 300 15 315 P 6/1/2021
104 250 10 260 P 8/1/2021
105 350 10 360 P 9/1/2021
105 300 10 310 P 10/1/2021
Table 2
ID Prin Int Tot TranType TranDt
101 100 15 115 R 1/15/2021
103 300 15 315 R 6/2/2021
105 350 10 360 R 9/5/2021
105 300 10 310 R 10/5/2021
Final Output
Table 3
ID Prin Int Tot TranType TranDt Cat
101 100 15 115 P 1/1/2021 Rev
101 100 15 115 P 1/1/2021 Good
102 500 15 515 P 5/1/2021 Good
103 300 15 315 P 6/1/2021 Rev
104 250 10 260 P 8/1/2021 Good
105 350 10 360 P 9/1/2021 Rev
105 300 10 310 P 10/1/2021 Rev
I need to combine table 1 and table 2 and if combination of (ID Prin Int Tot) and TranType= P
matches Table 2 (ID Prin Int Tot) and TranType= R then
mark that row as Rev but 2nd row if duplicate should be marked as Good.
Output is shown in Table 3.
TranDt of Table 2 is good as long as it is >= Table1.TranDt.
I would appreciate any help on this query.
I tried grouping but I can't make it work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
冗长但产生所需的输出。
      nbsp; nbsp; nbsp; nbsp;  
Lengthy but produce the desired output.