解释SAS代码的含义(Interpretation of the SAS code meaning)

编程入门 行业动态 更新时间:2024-10-16 00:21:42
解释SAS代码的含义(Interpretation of the SAS code meaning)

请帮我解释一下SAS代码(我对sas很陌生):

DATA sample; SET sample; v_eq = mve; est_v_eq = v_eq; sig_eq = sige; WHERE optosey > 0 AND optprcey > 0; RUN;

解释:使用“样本” - 数据库。 定义“v_eq = mve”,“est_v_eq = v_eq”,“sig_eq = sige”仅适用于optosey> 0且optprcey> 0的观测值,对吗? 令人困惑的是,为什么“他们”定义“v_eq = mve”,“est_v_eq = v_eq”而不是直接“v_eq = mve”?

Please, help me to interpret the SAS code (I am quite new to sas):

DATA sample; SET sample; v_eq = mve; est_v_eq = v_eq; sig_eq = sige; WHERE optosey > 0 AND optprcey > 0; RUN;

Interpretation: Use "sample" - database. Define "v_eq = mve", "est_v_eq = v_eq", "sig_eq = sige" only for observations that have optosey > 0 AND optprcey > 0, am I right? What is confusing is that why do "they" define "v_eq = mve", "est_v_eq = v_eq" and not directly "v_eq = mve" ?

最满意答案

你的解释是大致正确的。 你的问题也是我问的问题。 我会说这取决于这个代码的目的; 有可能这是为了可读性而以这种方式写的; 如果你用英语说这个代码的目的,或许你就是这样描述它的。

我会警告说,这是非常糟糕的形式,但特别是这一部分:

data sample; set sample; where ... ;

通常当你做不可逆转的事情时,最好不要写入你正在阅读的数据集(因为你正在丢失数据)。 WHERE不仅适用上述转换; 它实际上会过滤进入的行,因此只有符合WHERE条件的行才会在输出数据集中结束。

Your interpretation is broadly right. Your question is a question I'd ask, also. I would say that it depends on the purpose of this code; it's possible that this is written this way for readability; if you were saying the purpose of this code in English, perhaps that's how you'd describe it.

I'd warn that this is fairly bad form, though, in particular this part:

data sample; set sample; where ... ;

Normally when you are doing something irreversible, it is best to not write to the same dataset that you're reading from (since you're losing data). WHERE does not only apply the above transformations; it actually filters the rows coming in, so only rows that qualify for the WHERE end up in the output dataset.

更多推荐

本文发布于:2023-07-27 20:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1294986.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:含义   代码   SAS   meaning   code

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!