在 SAS 过程中比较
首先,我对 SAS 几乎一无所知,而且我不是程序员而是会计师,但事情是这样的:
我试图比较两个数据集以识别它们之间的差异,所以我使用“proc Compare”命令作为如下所示:
proc compare data=table1 compare=table2
criterion=.01;
run;
这工作正常,但它按行和顺序进行比较,因此如果 table2 中途缺少一行,则该行之后的所有条目都将作为不相等而返回。
如何要求基于变量进行比较,以便 proc 比较找到与表 1 中的变量 X 关联的值,然后确保表 2 中的相同变量 X 具有相同的值?
First off, I know pretty much nothing about SAS and I am not a programmer but an accountant, but here it goes:
I am trying to compare two data sets to identify differences between them, so I am using the 'proc compare' command as follows:
proc compare data=table1 compare=table2
criterion=.01;
run;
This works fine, but it compares line by line and in order, so if table2 is missing a row half way through, then all entries after that row will be returned as not equal.
How do I ask the comparison to be made based on a variable so that the proc compare finds the value associated with variable X in table 1, and then makes sure that the same variable X in table 2 has the same value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PROC COMPARE 中的 ID 语句用于匹配行。此代码可能适合您:
在执行 PROC COMPARE 之前,您可能需要使用 PROC SORT 按 X 对数据进行排序。有关 ID 语句的详细信息,请参阅 PROC COMPARE 文档以确定是否应该排序。
以下是 PROC COMPARE 文档的链接:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000057814.htm
The ID statement in PROC COMPARE is used to match rows. This code may work for you:
You may need to use PROC SORT to sort the data by X before doing the PROC COMPARE. Refer to the PROC COMPARE documentation for details on the ID statement to determine if you should sort or not.
Here is a link to the PROC COMPARE documentation:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000057814.htm