BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
current_thing
Obsidian | Level 7

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!

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

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

View solution in original post

6 REPLIES 6
yabwon
Onyx | Level 15

Show the code. And log.

 

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sbxkoenk
SAS Super FREQ

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

Reeza
Super User

WHERE is what is used in PROCs, IF is primarily data steps and some select procedures that allow for data manipulation. 

PaigeMiller
Diamond | Level 26

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.

https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/p1cxl8ifdt8u0gn12wqbji8o5fq1.htm#p08fp...

 

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).

--
Paige Miller
ballardw
Super User

@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.

 

 

current_thing
Obsidian | Level 7

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1107 views
  • 2 likes
  • 6 in conversation