BookmarkSubscribeRSS Feed
rajeshalwayswel
Pyrite | Level 9

Which procedure we use if statement? As per my knowledge we don't use if statement in procedures? Why we don't use if statement in procedure?

5 REPLIES 5
LinusH
Tourmaline | Level 20
That question should be directed to Dr Jim, or seem like an early SW design decision.
My humble guess is that procedures generste results baded on prameters (options and local statements). IF on the other hand offers execution logic, and that is out of the scope for procedures.
Can you exemplify when IF in a PROC would be beneficial?
Data never sleeps
Astounding
Opal | Level 21

The very brief picture:  In a DATA step, IF deletes observations that have already been read in.  The deletion can be based on original values in the observation, or can be based on values calculated along the way by the DATA step.

 

However, the WHERE statement subsets observations before they get read into the DATA step.  By subsetting earlier, the WHERE statement (in many cases) is faster than the IF statement.  In addition, the WHERE statement is available for procedures as well as the DATA step.  Since procedures don't calculate new variables, and procedures have the WHERE statement available, there is no need for an IF statement there.

WarrenKuhfeld
Rhodochrosite | Level 12

Actually, a number of procedures use IF statements.  They use a system called CMP that provides programming capabilities.  Here is one example, NLIN.  https://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_nlin_sect01... I know some of the OR procs have complicated syntax too, so they probably do.  IML of course does.  Look at the documentation, it will tell you.  There might be a list of CMP procs somewhere.  I could more easily check if I were in my office.  Most procedures do not use IF statements.

Patrick
Opal | Level 21

@rajeshalwayswel

To subset data many procedure allow for a WHERE statement (which is more like SQL syntax).

 

When working with SAS tables you can also use a WHERE statement as data set option to subset records:

Proc <some proc> data=source(where=(<condition>));
...

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 824 views
  • 0 likes
  • 6 in conversation