Alberto Alvarez
Alberto Alvarez

Reputation: 855

Interpretation of the SAS code meaning

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

Upvotes: 0

Views: 42

Answers (1)

Joe
Joe

Reputation: 63424

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.

Upvotes: 1

Related Questions