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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.