请帮我解释一下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.
更多推荐
发布评论