关于“数据合并”在SAS
我正在研究SAS中的数据合并,发现下面的例子
data newdata;
merge yourdata (in=a) otherdata (in=b);
by permno date;
我不知道“(in=a)”和“(in=b)”是什么意思?谢谢。
I am studying data merge in SAS, and find the following example
data newdata;
merge yourdata (in=a) otherdata (in=b);
by permno date;
I do not know what do "(in=a)" and "(in=b)" mean? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
yourdata(in=a)
在程序数据向量中创建一个名为“a”的标志变量,如果记录来自 yourdata,则该变量包含 1,否则包含 0。然后,您可以使用这些变量根据记录的来源执行条件操作。则可能会更容易理解
如果您看到假设在此步骤中需要操作数据中的记录,而不是其他数据中的记录,
,然后您可以执行类似的操作这些变量的一个明显用途是控制将进行哪种“合并”使用
if
语句发生。例如,if ThisRecordIsFromYourData and ThisRecordIsFromOtherData;
将使 SAS 仅包含与两个输入数据集的 by 变量匹配的行(如内部联接)。yourdata(in=a)
creates a flag variable in the program data vector called 'a' that contains 1 if the record is from yourdata and 0 if it isn't. You can then use these variables to perform conditional operations based on the source of the record.It might be easier to understand if you saw
Suppose that records from yourdata needed to be manipulated in this step, but not those from otherdata, you could then do something like
An obvious use for these variables is to control what kind of 'merge' will occur, using
if
statements. For example,if ThisRecordIsFromYourData and ThisRecordIsFromOtherData;
will make SAS only include rows that match on the by variables from both input data sets (like an inner join).