I read on this forum that IF and WHERE statements can be used in Data step, but in proc steps only IF can be used. I've tried it and in proc means, for example, if can't be used but where can. Is this true for all proc steps? Thanks!
In PROC (PROCEDURE) steps, only WHERE can be used!
There are very few PROCs that allow for (data-step-like) programming statements (NLIN, NLMIXED, MCMC, MODEL, REPORT, ...). In these PROCs you can also use "IF", but in the big majority of PROCS no "IF" is allowed, only "WHERE".
Koen
Show the code. And log.
In PROC (PROCEDURE) steps, only WHERE can be used!
There are very few PROCs that allow for (data-step-like) programming statements (NLIN, NLMIXED, MCMC, MODEL, REPORT, ...). In these PROCs you can also use "IF", but in the big majority of PROCS no "IF" is allowed, only "WHERE".
Koen
WHERE is what is used in PROCs, IF is primarily data steps and some select procedures that allow for data manipulation.
I read on this forum that IF and WHERE statements can be used in Data step
But the two statements, IF and WHERE, are not completely interchangeable, there are times when only IF will work and vice versa.
but in proc steps only IF can be used
As others have pointed out, most PROCs only allow WHERE and do not allow IF (there are a few exceptions).
@current_thing wrote:
I read on this forum that IF and WHERE statements can be used in Data step, but in proc steps only IF can be used. I've tried it and in proc means, for example, if can't be used but where can. Is this true for all proc steps? Thanks!
Post a link to the post that says "but in proc steps only IF can be used."
I will hope that you are not confusing the macro language %if with the data step if as they serve two quite different roles. There is no macro language "%where" provided by SAS (I won't say that someone hasn't written a macro function with that name) so is a possible source of confusion for those that haven't become familiar enough with SAS.
Yikes, I misread it. I went back to this forum and it actually said the reverse of what I put in the post 🙄
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.