BookmarkSubscribeRSS Feed
kuridisanjeev
Quartz | Level 8

Hi..

"Why If condition won't work in Procedures"????

As Per my knowledge IF condition works only in  Proc Report Procedure that too in Compute block only.

Could any one explain me why IF won't works in all other procedures??

Thanks in Advance 🙂

Regards.

Sanjeev.K

3 REPLIES 3
ballardw
Super User

The short answer: the procedures weren't programmed that way.

My guess why not: make sure your data is what you want to analyze before going to procedures else they get very complicated to program and maintain.

What procedure do want to use that you think NEEDS an IF statement?

If you want a procedure to process some of the data based on a condition that is accomplished with a WHERE statement as part of the procedure or as a data set option;

Reeza
Super User

Because there's a WHERE clause and its more efficient that IF statements.

SASKiwi
PROC Star

WHERE statements just subset or filter your data.

IF statements do a whole lot more than just filter data. Their primary use in DATA steps is conditional processing (IF condition true then do something), hence their implementation in REPORT procedure COMPUTE blocks.

Doing IF conditional processing in procedures other than REPORT doesn't make sense because their purpose is to transform data and that can be handled in the DATA step. And if all you want to do is filter data then WHERE statements are available for that.


hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1289 views
  • 1 like
  • 4 in conversation