关于“数据合并”在SAS

发布于 2024-10-13 06:15:40 字数 167 浏览 6 评论 0原文

我正在研究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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酷到爆炸 2024-10-20 06:15:41

yourdata(in=a) 在程序数据向量中创建一个名为“a”的标志变量,如果记录来自 yourdata,则该变量包含 1,否则包含 0。然后,您可以使用这些变量根据记录的来源执行条件操作。

则可能会更容易理解

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

如果您看到假设在此步骤中需要操作数据中的记录,而不是其他数据中的记录,

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

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

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;

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文