Hello,
I realised that the subset of data SAS creates when I use the WHERE statement in different lines is different.
For example, I often use:
DATA x (WHERE=(variable=1)
SET y
. . .
But I recently used
DATA x;
SET y;
WHERE=variable=1;
. . .
And the outputs were different. Would someone please explain to me why there is a difference?
Thank you.
Hi Angmar,
The difference there is that the first example, using where as a dataset option on the data statement, subsets the output dataset after all the processing in the data step has been done. The second example, using the where statement, subsets the input dataset(s) before all of the data processing. So, if the value of "variable" changes at all during the data step, the results of those two examples will be different.
Hope that explains it for you.
Joshua
Hi Angmar,
The difference there is that the first example, using where as a dataset option on the data statement, subsets the output dataset after all the processing in the data step has been done. The second example, using the where statement, subsets the input dataset(s) before all of the data processing. So, if the value of "variable" changes at all during the data step, the results of those two examples will be different.
Hope that explains it for you.
Joshua
WHERE=variable=1;
When used in a data step is an assignment statement NOT a WHERE statement.
Try using valid syntax.
WHERE variable = 1;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.