DATA Step, Macro, Functions and more

SQLLDR followed by %if (1) %then %let sqlldr_rc=&sysrc;

Reply
Contributor
Posts: 55

SQLLDR followed by %if (1) %then %let sqlldr_rc=&sysrc;

Does anybody know exactly how the %if (1) %then %let sqlldr_rc=&sysrc line works?

I'm not familiar with %if (1)
N/A
Posts: 0

Re: SQLLDR followed by %if (1) %then %let sqlldr_rc=&sysrc;

Expression in %if can be any valid macro expression that resolves to an integer. If expression is evaluated to zero, then it is false and the %then text is not processed. If it resoles to any integer other than zero, then the expression is true, and the %then text is processed. If it resolves to null or to any noninteger value, an error message is issued.
Super Contributor
Super Contributor
Posts: 3,174

Re: SQLLDR followed by %if (1) %then %let sqlldr_rc=&sysrc;

The SAS macro code is using a technique to force a TRUE condition test result. A value of 1 is TRUE and a value of 0 is false. You can see this processing decision during SAS code compilation if you turn on:

options source source2 macrogen symbolgen mlogic;



Scott Barry
SBBWorks, Inc.
Contributor
Posts: 55

Re: SQLLDR followed by %if (1) %then %let sqlldr_rc=&sysrc;

Thanks! I didn't expect the (1) to force a true test result. I'm not sure why the programmer didn't just code

%let sqlldr_rc=&sysrc;

Maybe this is a little slop accidently left in the code.
Super User
Posts: 5,437

Re: SQLLDR followed by %if (1) %then %let sqlldr_rc=&sysrc;

In conditional logic, 1 means TRUE. So your %if will always be true, and the assignment of sqlldr_rc will always happen.

/Linus
Data never sleeps
Ask a Question
Discussion stats
  • 4 replies
  • 127 views
  • 0 likes
  • 4 in conversation