I tried a data step with two where statements and realised that only the second where condition is affecting the output - see sample code below:
data result_2where_conditions;
set class_birthdate;
where Registration = 'C';
where Age = 12;
run;
Can somebody shed some light on why this happens?
Thanks heaps.
Only one WHERE statement can take effect, the second overrides the first. Combine both conditions in one statement with AND.
Only one WHERE statement can take effect, the second overrides the first. Combine both conditions in one statement with AND.
While this is valid and works, I would not even teach it, as sooner or later someone comes up with
where condition1;
/* 1000 lines of data step code */
where same and condition2;
/* another 1000 lines of data step code */
where same and condition3;
which is horrible to debug and maintain.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.