08-20-2016 09:46 PM
My grad student wrote a SAS program where he kept a small number of variables from a larger dataset and in the same program created some new variables from the ones he kept.
He noticed that the log reported operations performed on missing data when he knew he had none. To our dismay, we discovered that the newly created variables and renamed variables were moved to the next line of data so that the new variables were now paired with a different id.
When I ran the keep statement in a separate program from the steps that created the new variables, this did not happen (see both programs, log, and output in attached document).
What went wrong? The potential for this type of error to wreak havoc on a dataset worries me, so I am very anxious to understand it.
Version is SAS 9.4
Many thanks to anyone who can provide insights.
08-20-2016 10:00 PM
Lines 338-341: Calculated values are missing because the data is read AFTER the calculations are done. Move the set statement before math operations.
08-20-2016 10:15 PM
Indeed! Most errors are reflected in one way or another in the log. Don't hesitate to consult again if you see anything suspicious.