Help using Base SAS procedures

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

Reply
Super Contributor
Posts: 276

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

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

Super User
Posts: 10,500

Re: Why If condition won't work in Procedures???

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;

Super User
Posts: 17,829

Re: Why If condition won't work in Procedures???

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

Super User
Posts: 3,106

Re: Why If condition won't work in Procedures???

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.


Ask a Question
Discussion stats
  • 3 replies
  • 228 views
  • 1 like
  • 4 in conversation