According to the Prep Guide : When PROC IMPORT reads raw data, SAS sets the value of each variable in the DATA step to missing at the beginning of each cycle of execution, with these exceptions: Variables that are named in a RETAIN statement variables that are created in a sum statement Automatic variables In contrast, when reading variables from a SAS data set, SAS sets the values to missing only before the first cycle of execution of the DATA step. Therefore, the variables retain their values until new values become available (for example, through an assignment statement or through the next execution of a SET or MERGE statement). Variables that are created with options in a SET or MERGE statement also retain their values from one cycle of execution to the next. I don't understand this part of the data step execution. For me, with each new iteration, the variables are set to 'missing' for the following code, unless I write "retain total;" or "total+var1;" : data dataset.new;
set dataset.old;
total=sum(total,var1);
run; which is confirmed when I execute the code. However, the bolded part seems to say the opposite, as dataset.old is a SAS data set: the total value shouldn't be reset to missing and var1 would be added to total. While the book has probably no error and the code is executed as I expect, what do I miss about its explanation ?
... View more