BookmarkSubscribeRSS Feed
Wouter
Obsidian | Level 7
Hi,

Within 2 weeks, I've got the Base exam. After reading a lot (don't have access to the actual SAS right now, so I can't find out this question for myself), I want to know what will happen with the following code if there are more statements between the IF statement and the RUN statement:

Data XX.YY
Input ...
If tolerance="D";
TotalTime=(Timemin*60)+timesec;

run;

Will all statements after the IF statement only execute when tolerance="D", or does the IF statement only applies to the variable assignment (Totaltime)?

To put it another way, what is the value of TEST when running this code when tolerance="A":

Data XX.YY
Input ...
If tolerance="D";
TotalTime=(Timemin*60)+timesec;
TEST=6;
run;

Thanks in advance!
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
That particular form of the IF statement (the one that looks like the front end of an IF statement) is called a "subsetting" IF. It acts like a funnel to the rest of the program. When an observation meets the subsetting IF condition, it is allowed passage through the funnel to the rest of the logic (and the output) in the program. When an observation does NOT meet the condition, it is essentially deleted from the input buffer and the next observation in the input file is read and continues to process. This means, for example, in your hypothetical case, that the data set XX.YY would NOT have -any- observations with TOLERANCE='A' (assuming that there were no explicit OUTPUT statements before the subsetting IF).

For a description of the subsetting IF, read this in the documentation:
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000201978.htm

cynthia
Wouter
Obsidian | Level 7
Thank you very much for this info!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 658 views
  • 0 likes
  • 2 in conversation