本文介绍了关于“数据合并"在 SAS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究SAS中的数据合并,并找到以下示例

I am studying data merge in SAS, and find the following example

data newdata;
merge yourdata (in=a) otherdata (in=b);
by permno date;   

我不知道(in=a)"和(in=b)"是什么意思?谢谢.

I do not know what do "(in=a)" and "(in=b)" mean? Thanks.

推荐答案

yourdata(in=a) 在名为a"的程序数据向量中创建一个标志变量,如果记录是从 yourdata 和 0 如果不是.然后,您可以使用这些变量根据记录的来源执行条件操作.

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

data newdata;
merge yourdata(in=ThisRecordIsFromYourData) otherdata(in=ThisRecordIsFromOtherData);
by permno date;
run;

假设在此步骤中需要操作来自 yourdata 的记录,而不是来自其他数据的记录,那么您可以执行类似的操作

Suppose that records from yourdata needed to be manipulated in this step, but not those from otherdata, you could then do something like

data newdata;
merge yourdata(in=ThisRecordIsFromYourData) otherdata(in=ThisRecordIsFromOtherData);
by permno date;
if ThisRecordIsFromYourData then do;
  * some operation here for yourdata records only ;
end;
run;

这些变量的一个明显用途是使用 if 语句控制将发生的合并"类型.例如,if ThisRecordIsFromYourData 和 ThisRecordIsFromOtherData; 将使 SAS 只包含匹配来自两个输入数据集的 by 变量的行(如内连接).

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).

这篇关于关于“数据合并"在 SAS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 05:53