data _null_;
if 1=1 then
call execute('%extractTable();');
call execute('%scoreUpdate()');
call execute('%writeTable();');
call execute(
'proc sql noprint;
insert into tableA(date,tag)
set date=today(),
tag=1;');
else call execute('%writeIndex();');
run;
return Error 160-185:no match if-then statement
the problem is caused calling execute multiple macros..please fix the sas codes..thanks!
One version:
data _null_;
if 1=1 then
call execute
(' %nrstr( %extractTable() %scoreUpdate() %writeTable() )
proc sql noprint;
insert into tableA(date,tag)
set date=today(),
tag=1;
');
else call execute('%nrstr(%writeIndex())');
run;
It's possible that adding %NRSTR is overkill and unnecessary. But there's no way to know without seeing the contents of the four macros.
Consider whether a QUIT statement should be added at the end of PROC SQL.
As for the error you mentionned, if several instructions have to be executed when a given condition is met, they have to be enclosed by do;...end;
if (<condition>) then do;
<instruction1>
<instruction2>
...
end;
One version:
data _null_;
if 1=1 then
call execute
(' %nrstr( %extractTable() %scoreUpdate() %writeTable() )
proc sql noprint;
insert into tableA(date,tag)
set date=today(),
tag=1;
');
else call execute('%nrstr(%writeIndex())');
run;
It's possible that adding %NRSTR is overkill and unnecessary. But there's no way to know without seeing the contents of the four macros.
Consider whether a QUIT statement should be added at the end of PROC SQL.
The use of %nrstr depends on the contents of the macros. If they only have macro variables/parameters used, %nrstr is not needed. But if there's logic in there (%if %then %else), or steps that create macro variables for later use, you can get into timing problems, as macro statements will be executed as soon as they are pushed onto the execution stack, while data or proc steps cannot run before the current data step finishes.
%nrstr prevents such premature resolution of macros.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.