If you use %IF in open code (outside a macro), it has to have %DO-%END blocks for the %THEN and %ELSE branches.
Also note that the "open code %IF" is a fairly recent addition to the SAS system, so you need to have at least 9.4M5, IIRC.
And also note that you cannot use INPUT in %SYSFUNC, you need to use INPUTN or INPUTC.
Hi @Rajeshganta,
Once you have fixed the issue causing the error, you will probably also want to look at the %let statements, as you don't need an ampersand ("&") before the variable you are assigning, as you have done for num and email, you only need the ampersand in front when you want to use the value that the variable is holding.
Kind regards,
Amir.
In open code you need %DO/%END blocks.
You don't need the INPUT() code. The %EVAL() macro function that SAS uses for %IF conditions knows how to perform integer arithmetic.
%let num=101;
%if &num GE 100 %then %do;
%let email="raj@gma.com";
%end;
If you need to perform floating point calculations or use date literals then use %SYSEVALF().
%if %sysevalf(&num GE 100) %then %do;
You expand the %IF with %ELSE:
%if <condition>
%then %do;
....
%end;
%else %do;
....
%end;
Hi @Rajeshganta,
To find out more about the special requirements / limitations of using %if in open code then you can read this SAS blog post.
Thanks & kind regards,
Amir.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.